template-backend/docker-compose.yaml

66 lines
1.4 KiB
YAML
Raw Normal View History

2024-08-12 19:22:51 +00:00
services:
db:
image: postgres:latest
command: postgres -c 'max_connections=200'
environment:
- POSTGRES_USER=${DB_USER}
- POSTGRES_PASSWORD=${DB_PASSWORD}
- POSTGRES_DB=${DB_NAME}
volumes:
- postgresql-data:/var/lib/postgresql/data
restart: on-failure
nginx:
command: nginx -g "daemon off;"
depends_on:
- app
- api
image: nginx:alpine
restart: on-failure
volumes:
- ./nginx/nginx.conf:/etc/nginx/nginx.conf
- static:/var/www/app/static
ports:
- "8000:8000"
app:
build:
context: .
dockerfile: Dockerfile
command: bash -c 'while !</dev/tcp/db/5432; do sleep 1; done; python3 manage.py collectstatic --no-input; python3 manage.py migrate; uvicorn core.asgi:application --port 8000 --host 0.0.0.0'
volumes:
- ./src/:/app/
- static:/app/static
depends_on:
- db
- redis
restart: on-failure
env_file:
- .env
api:
build:
context: .
dockerfile: Dockerfile
command: bash -c 'uvicorn core.asgi:fastapp --port 8000 --host 0.0.0.0'
volumes:
- ./src/:/app/
depends_on:
- db
- redis
restart: on-failure
env_file:
- .env
redis:
image: redis:latest
command: redis-server --requirepass ${REDIS_PASSWORD}
volumes:
- redis-data:/data
restart: on-failure
volumes:
postgresql-data:
static:
redis-data:
external: false