Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Rmarieta authored Mar 21, 2024
1 parent 992ea71 commit 7ab8589
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,37 @@

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.
- An Nginx load balancer.
- 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 <environment>] [-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.<env>.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.

0 comments on commit 7ab8589

Please sign in to comment.