Step 5-alt : Deploy your app on prod with docker-compose (without kubernetes)

Note

We consider that you have previously configured a Dockerfile file according to instructions described in Step 2:Containerize your app

We consider that you have tested your application with docker compose according to instructions described in Step 3

We consider that your project is successfully building images at each commit.

We consider that the server have docker and docker compose installed

Although our goal is to empower you to run your application in kubernetes, we here provide guidance on how to run it in production in a virtual machine. In this section, you will define your settings related to your project, and then be able to run the image built by gitlab after the last commit.

Run the example

cd docker-compose-for-prod/
docker compose --env-file .example.env up

Configure your .env

In the .env file we provide example to run the compose :

Given a project hosted at # If your project is hosted at https://gitlab.pasteur.fr/ada-team/my-project/ where the production branch is named main, the file is:

CI_PROJECT_NAMESPACE=ada-team
CI_PROJECT_NAME=my-project
CI_REGISTRY=registry-gitlab.pasteur.fr
PROD_BRANCH=main

Run it

cd docker-compose-for-prod/
docker compose up -d

With private registry

You have to auth before starting the compose. Given a .auth file containing :

DEPLOY_USER=my-user
DEPLOY_TOKEN=not-secured-password

You should then do:

cd docker-compose-for-prod/
source .auth
source .env
echo $DEPLOY_TOKEN | docker login --username $DEPLOY_USER $CI_REGISTRY --password-stdin
docker compose up -d

more info can be found at https://docs.docker.com/reference/cli/docker/login/#password-stdin

Administrate your container

Information on how to manage the containers can be found at Administrate your container

How to open it to the world

Your application is now hosted in a VM, exposed on port 3838 only in http. The rest of the configuration for routing network traffic arriving at https://my-app.my-institut.fr onto your app is up to the system administrators of your organization. Providing them the docker-compose.yaml file, and a link to this page will help them finalizing the configuration.