forked from mtusi2026/mtusi2026lab2
56 lines
1.2 KiB
YAML
56 lines
1.2 KiB
YAML
services:
|
|
postgres:
|
|
image: postgres:16.10-bookworm
|
|
restart: unless-stopped
|
|
environment:
|
|
POSTGRES_USER: messenger
|
|
POSTGRES_DB: messenger
|
|
POSTGRES_PASSWORD_FILE: /run/secrets/postgres_password
|
|
secrets:
|
|
- postgres_password
|
|
volumes:
|
|
- pgdata:/var/lib/postgresql/data
|
|
ports:
|
|
- "127.0.0.1:5432:5432"
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "pg_isready -U messenger -d messenger"]
|
|
interval: 5s
|
|
timeout: 3s
|
|
retries: 10
|
|
|
|
migrate:
|
|
build: .
|
|
image: mtusi-messenger:lab2
|
|
command: ["alembic", "upgrade", "head"]
|
|
env_file: .env
|
|
secrets:
|
|
- database_url
|
|
depends_on:
|
|
postgres:
|
|
condition: service_healthy
|
|
restart: "no"
|
|
|
|
api:
|
|
build: .
|
|
image: mtusi-messenger:lab2
|
|
restart: unless-stopped
|
|
env_file: .env
|
|
secrets:
|
|
- database_url
|
|
ports:
|
|
- "127.0.0.1:8080:8080"
|
|
depends_on:
|
|
postgres:
|
|
condition: service_healthy
|
|
migrate:
|
|
condition: service_completed_successfully
|
|
|
|
secrets:
|
|
postgres_password:
|
|
file: ./secrets/postgres_password
|
|
database_url:
|
|
file: ./secrets/database_url
|
|
|
|
volumes:
|
|
pgdata:
|