Skip to content

Deploy your app to production

This guide will show you how to deploy an app. It assumes that you used the app boilerplate repository that is presented in the Create your first social app guide.

The app boilerplate repository includes a Docker configuration with everything that is needed for a deployment to production:

  • Your app’s backend
  • Your app’s frontend
  • Traefik to orchestrate domain names and SSL certificates
  • Apache Jena Fuseki to store semantic data
  • Redis used for cache, jobs queue and by the OIDC provider
  • Arena to watch the jobs queue

Installation steps

A Linux server with 4Gb of RAM is required for Fuseki to work properly, otherwise there is a high risk that it runs out of memory and gets killed.

Point your domain to your server IP

You will need only one domain name. By default, the frontend will be in the root directory of the domain, while the backend will be in the /api directory (and the /.well-known path will also point to the backend).

Go to your domain provider and point your domain name to your server IP (with a A-type registration).

Clone your app repository

Connect to your server in SSH and clone your app repository. If all your code is still local, we recommend to either fork the app boilerplate repository (which will allow you to benefit from improvements) or to create a new repository from scratch.

Terminal window
git clone https://github.com/my-username/my-app.git my-app
cd my-app

Install Docker

We have prepared a script for this:

Terminal window
./install-docker.sh

If that doesn’t work with your server config, you can follow Docker installation instructions.

Set the environment variables

Copy the .env.production file to a .env.production.local file (cp .env.production .env.production.local) and set your server settings. This file (that is not committed by Git) will be used when loading the docker-compose-prod.yml file.

.env.production.local
# Mandatory information
DOMAIN_NAME=exampleapp.com
BACKEND_PATH=/api
APP_NAME="Example app"
APP_DESCRIPTION="Boilerplate for ActivityPods apps"
APP_LANG=en
LETSENCRYPT_EMAIL=
FUSEKI_PASSWORD=
# If you want to enforce a Pod provider for this app
POD_PROVIDER_BASE_URL=
# If you want to publish the image to a Docker registry
BACKEND_DOCKER_IMAGE=
FRONTEND_DOCKER_IMAGE=

Deploy to production

Make sure you have make installed, then you can now launch the Docker containers with this command:

Terminal window
make start-prod

If there is a problem, you can see the backend logs with the make logs-backend-prod command. Errors will be displayed here. You can also call make attach-backend-prod, which will give you access to your app’s Moleculer CLI.

Explore your server

The frontend should now be available at the domain you chose.

The backend app is visible in the /api/app path.

Fuseki provides also a frontend to see the datasets. It is available on port 3030 of your server. The login is “admin” and the password is the one you chose on the environment variables.

You can also see the jobs queue by connecting to Arena on port 4567 of your server.

Alternative: Build Docker images

If you want to deploy several applications on the same server, we make it easy to publish the Docker images of your app’s backend and frontend, and then use them.

First edit the .env.production.local file and enter, at the bottom, the name of the images you want to publish.

.env.production.local
# If you want to publish the image to a Docker registry
BACKEND_DOCKER_IMAGE=
FRONTEND_DOCKER_IMAGE=

The following commands will publish your images to Docker Hub:

Terminal window
make publish-backend-latest
make publish-frontend-latest

You can then use these images in your own docker-compose.yml file.

Maintenance

Datasets compaction

It is required to regularly compact the datasets generated by Fuseki, otherwise they may grow very large. Unfortunately, due to the extension we developed to handle WAC permissions, it is required to stop Fuseki, compact it and launch it again.

We provide a script to do this which can be run like this:

Terminal window
./compact-datasets.sh

To call it every Thursday night at 4am, you can set a cron job by calling crontab -e and entering a new line like this (make sure you set the absolute path to the compact-datasets.sh script):

0 4 * * TUE /ABSOLUTE_PATH_TO/compact-datasets.sh >> ~/cron.log 2>&1