version: '3.9' services: postgres: image: postgres:latest container_name: reddit-postgres hostname: postgres ports: - 5432:5432 user: postgres volumes: - postgres-data:/var/lib/postgresql/data restart: unless-stopped healthcheck: test: ['CMD', 'pg_isready'] interval: 5s timeout: 3s retries: 10 redis: image: redis:6.2-alpine container_name: reddit-redis ports: - '6379:6379' command: redis-server --save 20 1 --loglevel warning environment: - ALLOW_EMPTY_PASSWORD=yes healthcheck: test: ['CMD', 'redis-cli', 'ping'] interval: 1s timeout: 3s retries: 30 volumes: - cache:/data restart: unless-stopped api: stdin_open: true build: context: . dockerfile: server.dockerfile container_name: reddit-api ports: - '4000:4000' - '9229:9229' restart: always depends_on: postgres: condition: service_healthy redis: condition: service_healthy environment: - REDIS_HOSTS=local:redis:6379 volumes: postgres-data: cache: