services:
  api:
    image: node:20-alpine
    ports:
      - "3000:3000"
    environment:
      NODE_ENV: production
      PORT: "3000"
    depends_on:
      - db
      - cache
    restart: unless-stopped
    healthcheck:
      test:
        - CMD
        - curl
        - -f
        - http://localhost:3000/health
      interval: 30s
      timeout: 10s
      retries: 3
    volumes:
      - "app-data:/data"

  db:
    image: postgres:16-alpine
    environment:
      POSTGRES_DB: appdb
      POSTGRES_USER: app
      POSTGRES_PASSWORD: secret
    volumes:
      - "pg-data:/var/lib/postgresql/data"

  cache:
    image: redis:7-alpine
    restart: always

volumes:
  app-data:
  pg-data:
    driver: local
