services: api: build: . ports: - "127.0.0.1:8080:8080" env_file: .env secrets: - database_url - cache_url depends_on: postgres: condition: service_healthy redis: condition: service_healthy healthcheck: test: ["CMD", "wget", "--spider", "-q", "http://localhost:8080/health/live"] interval: 30s timeout: 3s retries: 3 migrate: image: migrate/migrate:v4.17.0 volumes: - ./migrations:/migrations command: - "-path" - "/migrations" - "-database" - "postgres://messenger:messenger@postgres:5432/messenger?sslmode=disable" - "up" depends_on: postgres: condition: service_healthy postgres: image: postgres:16-alpine environment: POSTGRES_USER: messenger POSTGRES_PASSWORD_FILE: /run/secrets/postgres_password POSTGRES_DB: messenger secrets: - postgres_password volumes: - pg_data:/var/lib/postgresql/data healthcheck: test: ["CMD-SHELL", "pg_isready -U messenger -d messenger"] interval: 5s timeout: 3s retries: 5 redis: image: redis:7-alpine command: ["redis-server", "--appendonly", "yes"] volumes: - redis_data:/data healthcheck: test: ["CMD", "redis-cli", "ping"] interval: 5s timeout: 3s retries: 5 secrets: postgres_password: file: ./secrets/postgres_password database_url: file: ./secrets/database_url cache_url: file: ./secrets/cache_url volumes: pg_data: redis_data: