version: '3.8'

services:
  # Banco de dados PostgreSQL
  db:
    image: postgres:15
    container_name: allure_db
    environment:
      POSTGRES_DB: allure_db
      POSTGRES_USER: allure_user
      POSTGRES_PASSWORD: allure_password
    volumes:
      - postgres_data:/var/lib/postgresql/data
    ports:
      - "5432:5432"
    networks:
      - allure_network
    restart: unless-stopped

  # Aplicação Django
  web:
    build: .
    container_name: allure_web
    environment:
      - DEBUG=False
      - SECRET_KEY=your-secret-key-here
      - DATABASE_URL=postgresql://allure_user:allure_password@db:5432/allure_db
      - ALLOWED_HOSTS=localhost,127.0.0.1,0.0.0.0
    volumes:
      - ./media:/app/media
      - ./staticfiles:/app/staticfiles
    ports:
      - "8000:8000"
    depends_on:
      - db
    networks:
      - allure_network
    restart: unless-stopped
    command: >
      sh -c "python manage.py migrate &&
             python manage.py collectstatic --noinput &&
             gunicorn --bind 0.0.0.0:8000 --workers 3 allure_project.wsgi:application"

  # Nginx (opcional, para produção) - Comentado temporariamente
  # nginx:
  #   image: nginx:alpine
  #   container_name: allure_nginx
  #   ports:
  #     - "80:80"
  #     - "443:443"
  #   volumes:
  #     - ./nginx.conf:/etc/nginx/nginx.conf:ro
  #     - ./staticfiles:/app/staticfiles:ro
  #     - ./media:/app/media:ro
  #   depends_on:
  #     - web
  #   networks:
  #     - allure_network
  #   restart: unless-stopped

volumes:
  postgres_data:

networks:
  allure_network:
    driver: bridge
