version: '3.8'

services:
  api:
    build: 
      context: .
      dockerfile: Dockerfile
    container_name: ads-analytics-api
    ports:
      - "${PORT:-3660}:3660"
    env_file:
      - .env
    environment:
      - NODE_ENV=production
      - DB_HOST=db
      - REDIS_HOST=redis
    depends_on:
      - db
      - redis
    restart: always

  db:
    image: postgres:15-alpine
    container_name: ads-analytics-db
    ports:
      - "5433:5432"
    environment:
      - POSTGRES_USER=${DB_USER:-postgres}
      - POSTGRES_PASSWORD=${DB_PASSWORD:-postgres}
      - POSTGRES_DB=${DB_NAME:-ads_analytics}
    volumes:
      - postgres_data:/var/lib/postgresql/data
    restart: always

  redis:
    image: redis:alpine
    container_name: ads-analytics-redis
    ports:
      - "6380:6379"
    restart: always

volumes:
  postgres_data:
