forked from mtusi2026/mtusi2026lab2
102 lines
2.5 KiB
YAML
102 lines
2.5 KiB
YAML
name: mtusi2026lab2
|
|
services:
|
|
postgres:
|
|
image: postgres:17.6-alpine3.22
|
|
environment:
|
|
POSTGRES_USER: messenger
|
|
POSTGRES_DB: messenger
|
|
POSTGRES_PASSWORD_FILE: /run/secrets/postgres_password
|
|
secrets:
|
|
- postgres_password
|
|
volumes:
|
|
- postgres_data:/var/lib/postgresql/data
|
|
healthcheck:
|
|
test: [CMD-SHELL, 'pg_isready -U messenger -d messenger']
|
|
interval: 2s
|
|
timeout: 2s
|
|
retries: 30
|
|
cpus: 1.0
|
|
mem_limit: 512m
|
|
redis:
|
|
image: redis:7.4.5-alpine3.21
|
|
command: [redis-server, /usr/local/etc/redis/redis.conf]
|
|
volumes:
|
|
- redis_data:/data
|
|
- ./infra/redis.conf:/usr/local/etc/redis/redis.conf:ro
|
|
healthcheck:
|
|
test: [CMD, redis-cli, ping]
|
|
interval: 2s
|
|
timeout: 2s
|
|
retries: 30
|
|
cpus: 0.5
|
|
mem_limit: 128m
|
|
migrations:
|
|
image: mtusi-migrations:lab2
|
|
build:
|
|
context: .
|
|
target: migrations
|
|
environment:
|
|
GOOSE_DRIVER: postgres
|
|
GOOSE_DBSTRING: host=postgres user=messenger dbname=messenger sslmode=disable connect_timeout=5
|
|
POSTGRES_PASSWORD_FILE: /run/secrets/postgres_password
|
|
secrets:
|
|
- postgres_password
|
|
depends_on:
|
|
postgres:
|
|
condition: service_healthy
|
|
cpus: 0.5
|
|
mem_limit: 128m
|
|
api:
|
|
build: .
|
|
image: mtusi-messenger:lab2
|
|
environment: &api_environment
|
|
POSTGRES_HOST: postgres
|
|
POSTGRES_USER: messenger
|
|
POSTGRES_DB: messenger
|
|
POSTGRES_PASSWORD_FILE: /run/secrets/postgres_password
|
|
POSTGRES_MAX_CONNS: '10'
|
|
REDIS_ADDR: redis:6379
|
|
CURSOR_KEY_FILE: /run/secrets/cursor_key
|
|
SESSION_TTL_SECONDS: ${SESSION_TTL_SECONDS:-3600}
|
|
QUERY_TIMEOUT_MS: '2000'
|
|
secrets: &api_secrets
|
|
- postgres_password
|
|
- cursor_key
|
|
ports:
|
|
- '127.0.0.1:${PORT:-8080}:8080'
|
|
depends_on:
|
|
postgres:
|
|
condition: service_healthy
|
|
redis:
|
|
condition: service_healthy
|
|
migrations:
|
|
condition: service_completed_successfully
|
|
cpus: 1.0
|
|
mem_limit: 256m
|
|
stop_grace_period: 10s
|
|
tests:
|
|
image: mtusi-messenger-tests:lab2
|
|
profiles: [test]
|
|
build:
|
|
context: .
|
|
target: tests
|
|
environment:
|
|
<<: *api_environment
|
|
INTEGRATION_TESTS: '1'
|
|
secrets: *api_secrets
|
|
depends_on:
|
|
postgres:
|
|
condition: service_healthy
|
|
redis:
|
|
condition: service_healthy
|
|
cpus: 1.0
|
|
mem_limit: 1g
|
|
secrets:
|
|
postgres_password:
|
|
file: ./secrets/postgres_password
|
|
cursor_key:
|
|
file: ./secrets/cursor_key
|
|
volumes:
|
|
postgres_data:
|
|
redis_data:
|