61 lines
2.1 KiB
YAML
61 lines
2.1 KiB
YAML
services:
|
|
fastapi-app:
|
|
build:
|
|
context: ./backend
|
|
dockerfile: Dockerfile
|
|
target: dev
|
|
ports:
|
|
- "8000:8000"
|
|
volumes:
|
|
- ./backend/app:/app/app:ro
|
|
- ./backend/data:/app/data:ro
|
|
- ./backend/tests:/app/tests:ro
|
|
# Writable: `alembic revision --autogenerate` creates files in migrations/versions
|
|
- ./backend/migrations:/app/migrations
|
|
env_file:
|
|
- .env
|
|
environment:
|
|
- PYTHONPATH=${PYTHONPATH:-/app}
|
|
# Tests wipe their tables, so they use a separate database (created on demand)
|
|
- TEST_DATABASE_URL=postgresql+asyncpg://${POSTGRES_DATABASE_USER}:${POSTGRES_DATABASE_PASSWORD}@postgres:5432/${POSTGRES_DATABASE_DB}_test
|
|
command: sh -c "alembic upgrade head && uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload --reload-dir /app/app"
|
|
depends_on:
|
|
postgres:
|
|
condition: service_healthy
|
|
frontend:
|
|
build:
|
|
context: ./frontend
|
|
ports:
|
|
- "8080:80"
|
|
volumes:
|
|
# Static files are served as they are: edits show up on page reload
|
|
- ./frontend/index.html:/usr/share/nginx/html/index.html:ro
|
|
- ./frontend/exercises.html:/usr/share/nginx/html/exercises.html:ro
|
|
- ./frontend/parse.html:/usr/share/nginx/html/parse.html:ro
|
|
- ./frontend/users.html:/usr/share/nginx/html/users.html:ro
|
|
- ./frontend/login.html:/usr/share/nginx/html/login.html:ro
|
|
- ./frontend/css:/usr/share/nginx/html/css:ro
|
|
- ./frontend/js:/usr/share/nginx/html/js:ro
|
|
- ./frontend/vendor:/usr/share/nginx/html/vendor:ro
|
|
depends_on:
|
|
- fastapi-app
|
|
postgres:
|
|
image: postgres:15-alpine
|
|
env_file:
|
|
- .env
|
|
environment:
|
|
- POSTGRES_DB=${POSTGRES_DATABASE_DB}
|
|
- POSTGRES_USER=${POSTGRES_DATABASE_USER}
|
|
- POSTGRES_PASSWORD=${POSTGRES_DATABASE_PASSWORD}
|
|
ports:
|
|
- "${POSTGRES_DATABASE_PORT}:5432"
|
|
volumes:
|
|
- postgres_data:/var/lib/postgresql/data
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_DATABASE_USER} -d ${POSTGRES_DATABASE_DB}"]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 5
|
|
|
|
volumes:
|
|
postgres_data:
|