From 7ab85892a0ac3ad7e41f2029d43ee4de3672b584 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Mari=C3=A9tan?= Date: Thu, 21 Mar 2024 11:30:34 +0100 Subject: [PATCH] Update README.md --- README.md | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 7e52a5e..7d7515f 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,8 @@ Repository to test a backend architecture that can be spin up on AWS Elastic Beanstalk or on any device with Docker installed. +## Content + The backend consists in: - A PostgreSQL database. @@ -9,22 +11,28 @@ The backend consists in: - Flask containers running behind the load balancer and served over Gunicorn to enable multi-threading. - A Redis container to coordinate websocket connections/messages while having multiple Flask processes running at the same time. -To use this code, first rename `.env.example` to `.env` and set your own values. +## Build the Containers -To start the containers, a `run.sh` shell script is provided. It can be run with the following options: +To use this code, first rename `.env.example` to `.env` and set your own values. -- `-e`/`--env` : which has to be provided and is either of `debug`, `dev` and `prod`. This will determine which `docker-compose` will be used. -- `-v`/`--volumes` : if provided, first clears the volumes associated with the containers to start fresh. -- `-d`/`--detach` : if provided, runs `docker-compose` in detached mode. +To build the containers, there are multiple options. The `run.sh` shell script provides commands that can be run to spin up all the containers with some additional options. -For example, to run the `debug` version and start with empty volumes: +The `run.sh` script can be executed with: ``` -bash ./run.sh -e debug -v +bash ./run.sh [-e ] [-v] [-d] ``` -Then, to bring the containers down and clear the volumes, do: +The 3 flags are optional and do the following: + +- `-e`/`--env` is either of `debug`, `dev` or `prod` (default) and determines which `docker-compose..yml` to run. The `debug` environment has logging and development servers, as opposed to the `prod` environment. +- `-v`: if present, will first remove the volumes associated with the containers. For example to remove the content of the database while testing. If not present, will simply bring down all the containers before starting new ones. +- `-d`: if present, will run in detach mode. If not, will finish the execution with `docker-compose logs -f` which displays container logs in real-time in the current shell. + +Example (running the backend in `debug` mode and not in detach mode): ``` -docker-compose -f docker-compose.debug.yml down -v +bash ./run.sh -e debug -v ``` + +Then the API can be accessed from `http://localhost:1015/` since the Nginx load balancer is listening on that port.