version: '3.8'

services:
  # Main application service
  bank-sampah-app:
    build:
      context: .
      dockerfile: Dockerfile
      target: final
    container_name: bank-sampah-app
    ports:
      - "8080:8080"
      - "8081:8081"
    environment:
      - ASPNETCORE_ENVIRONMENT=Production
      - ASPNETCORE_URLS=http://+:8080
    volumes:
      # Mount configuration files (optional)
      - ./appsettings.Production.json:/app/appsettings.Production.json:ro
      # Mount logs directory
      - ./logs:/app/logs
    networks:
      - bank-sampah-network
    restart: unless-stopped
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:8080/health"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 40s

  # Nginx reverse proxy (optional)
  nginx:
    image: nginx:alpine
    container_name: bank-sampah-nginx
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro
      - ./nginx/ssl:/etc/nginx/ssl:ro
      - ./logs/nginx:/var/log/nginx
    networks:
      - bank-sampah-network
    restart: unless-stopped
    depends_on:
      - bank-sampah-app

networks:
  bank-sampah-network:
    driver: bridge