version: '3.8'

services:
  backend:
    build:
      context: .
      dockerfile: Dockerfile
      args:
        - NODE_ENV=${NODE_ENV:-production}
    image: toptran-backend:${NODE_ENV:-production}
    container_name: toptran-backend-${NODE_ENV:-production}
    restart: unless-stopped
    ports:
      - "${PORT:-5000}:${PORT:-5000}"
    env_file:
      - .env.${NODE_ENV:-production}
    environment:
      - NODE_ENV=${NODE_ENV:-production}
    volumes:
      - ./logs:/app/logs
    healthcheck:
      test: ["CMD", "sh", "-c", "curl -f http://localhost:${PORT:-5000}/sync/companies"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 40s

