From 60aa32422c4b04b7fcfcc27d0408247e93b36602 Mon Sep 17 00:00:00 2001
From: Bryan Brancotte <bryan.brancotte@pasteur.fr>
Date: Mon, 10 Jun 2024 18:41:18 +0200
Subject: [PATCH] document on how to run with compose in prod

---
 source/user_guide/index.rst            | 10 ++++
 source/user_guide/run_locally.rst      |  1 +
 source/user_guide/run_with_compose.rst | 72 ++++++++++++++++++++++++++
 source/user_guide/setup_project.rst    |  2 +
 4 files changed, 85 insertions(+)
 create mode 100644 source/user_guide/run_with_compose.rst

diff --git a/source/user_guide/index.rst b/source/user_guide/index.rst
index 1a755aa..4e15a6a 100644
--- a/source/user_guide/index.rst
+++ b/source/user_guide/index.rst
@@ -41,6 +41,16 @@ Run on kubernetes
 
 
 
+
+Run in prod with docker compose
+===============================================================================
+.. toctree::
+   :maxdepth: 3
+
+   run_with_compose
+
+
+
 Frequently Asked Questions
 ==========================
 .. toctree::
diff --git a/source/user_guide/run_locally.rst b/source/user_guide/run_locally.rst
index f4110a9..9ae531f 100644
--- a/source/user_guide/run_locally.rst
+++ b/source/user_guide/run_locally.rst
@@ -166,6 +166,7 @@ One command line is enough.
 .. note::
     | Press :kbd:`Ctrl` + :kbd:`C` to exit
 
+.. _admin_container:
 
 Administrate your container 
 ------------------------------
diff --git a/source/user_guide/run_with_compose.rst b/source/user_guide/run_with_compose.rst
new file mode 100644
index 0000000..dc8e2c1
--- /dev/null
+++ b/source/user_guide/run_with_compose.rst
@@ -0,0 +1,72 @@
+.. _run_compose:
+
+Running in production with docker compose
+-------------------------------------------------
+
+
+.. note::
+
+    We consider that you have configure previously a ``Dockerfile`` file according to instructions described in :ref:`Adapting the Dockerfile to your needs section<dockefile>`
+
+    We consider that you have configured the ``.gitlab-ci`` file, and your project is build images at each commit :ref:`according to the Setup the project<project_and_gitlab_ci>`
+
+    We consider that your computer/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
+*************************************************
+.. code-block:: bash
+    
+    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:
+
+.. code-block:: ini
+    
+    CI_PROJECT_NAMESPACE=ada-team
+    CI_PROJECT_NAME=my-project
+    CI_REGISTRY=registry-gitlab.pasteur.fr
+    PROD_BRANCH=main
+
+Run it
+*************************************************
+
+.. code-block:: bash
+
+    docker compose up -d
+
+With private registry
+*************************************************
+
+You have to auth before starting the compose. Given a .auth file containing :
+
+.. code-block:: ini
+
+    DEPLOY_USER=my-user
+    DEPLOY_TOKEN=not-secured-password
+
+You should then do:
+
+.. code-block:: bash
+
+    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 :ref:`admin_container`
\ No newline at end of file
diff --git a/source/user_guide/setup_project.rst b/source/user_guide/setup_project.rst
index f2010fa..bdb0ea7 100644
--- a/source/user_guide/setup_project.rst
+++ b/source/user_guide/setup_project.rst
@@ -1,3 +1,5 @@
+.. _project_and_gitlab_ci:
+
 Setup the project to run on Kubernetes
 ===============================================================================
 
-- 
GitLab