name: vp-lab3-medvedev x-api: &api image: vp-medvedev-lab3:local build: . cpus: ${API_CPUS:-1} mem_limit: ${API_MEMORY:-512m} deploy: replicas: ${API_REPLICAS:-2} stop_grace_period: 10s environment: APP_PORT: 8080 SESSION_TTL_SECONDS: ${SESSION_TTL_SECONDS:-3600} PG_MAX_CONNS: ${PG_MAX_CONNS:-8} GOMEMLIMIT: ${GO_MEMORY_LIMIT:-400MiB} secrets: [database_url, cache_url] depends_on: migrate: {condition: service_completed_successfully} valkey: {condition: service_started} networks: [private] services: postgres: image: postgres:18.6@sha256:74935e72241653ca55e0414067e6d8763aceb8a810eb51b452253ec3dcfc4336 cpus: 2 mem_limit: 768m environment: POSTGRES_USER: messenger POSTGRES_DB: messenger POSTGRES_PASSWORD_FILE: /run/secrets/pg_password secrets: [pg_password] volumes: [postgres:/var/lib/postgresql] healthcheck: test: [CMD-SHELL, pg_isready -U messenger -d messenger] interval: 2s timeout: 2s retries: 30 networks: [private] valkey: image: valkey/valkey:9@sha256:418652cfb58ef879d4978c33553735d7147016032d5aefaa14c828e611eb9dfd cpus: 0.25 mem_limit: 128m command: [valkey-server, /run/secrets/valkey_conf] secrets: [valkey_conf] volumes: [valkey:/data] networks: [private] migrate: image: vp-medvedev-lab3:local build: . command: [-migrate] cpus: 0.5 mem_limit: 256m secrets: [database_url] depends_on: postgres: {condition: service_healthy} networks: [private] api: <<: *api lb: image: haproxy:3.2-alpine@sha256:1c3568e520453cc8ba98c39501febcf450429c80e6cc27ecad779961d76e597c cpus: 0.5 mem_limit: 128m ports: ['127.0.0.1:${PUBLIC_PORT:-28203}:8080'] volumes: ['./config/haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro'] depends_on: api: {condition: service_started} networks: [private] volumes: postgres: valkey: networks: private: secrets: pg_password: {file: .local/pg_password} database_url: {file: .local/database_url} cache_url: {file: .local/cache_url} valkey_conf: {file: .local/valkey.conf}