Enhance support for docker-compose (#23)

* Fix docker-compose.yml

* Update DOCKER to describe the configuration

* Ensure postgres is running before spinning up frogress

* Add default config for docker-compose
This commit is contained in:
Luciano Ciccariello 2023-03-07 07:44:58 +00:00 committed by GitHub
parent 47b142adea
commit 31616f9132
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 2 deletions

4
.env
View File

@ -2,3 +2,7 @@ DEBUG=on
SECRET_KEY=django-insecure-4g&!7-muxr8a*6!pxk$agny_3z5w_bztudcbb7(*@ynco%$c6k
DATABASE_URL=sqlite:///db.sqlite3
ULTIMATE_API_KEY=meowp
POSTGRES_USER=user
POSTGRES_PASSWORD=pass
POSTGRES_PORT=5432
BACKEND_PORT=9000

View File

@ -5,6 +5,17 @@ There are 2 images that make up this project:
- `frogress` - the app itself, based upon [python:3.10-slim](https://hub.docker.com/_/python) image.
- `postgres` - [postgresql](https://hub.docker.com/_/postgres) database
## Configuration
The following environment variables in `.env` are required to run the services via docker-compose:
- `POSTGRES_USER` self-explanatory. Can be set to `user`.
- `POSTGRES_PASSWORD` self-explanatory. Can be set to `pass`.
- `POSTGRES_PORT` to connect to postgres externally. Can be set to `5432`.
- `BACKEND_PORT` the port to access the service to. Can be set to `9000`.
With the above configuration, you will be able to use the API via `http://localhost:9000`. You can also connect to postgres via `localhost:5432`.
## Persisted data
The database data is persisted to `./deployment/postgres/data`, this can be changed within the `docker-compose.yaml` file.

View File

@ -10,11 +10,13 @@ services:
volumes:
- ./deployment/postgres/data:/var/lib/postgresql/data
frogress:
depends_on:
- postgres
build:
context: .
dockerfile: deployment/frogress/Dockerfile
ports:
- "${BACKEND_PORT}:${BACKEND_PORT}"
- "${BACKEND_PORT}:8000"
environment:
POSTGRES_HOST: ${POSTGRES_HOST}
POSTGRES_HOST: postgres
POSTGRES_PORT: 5432