version: '3.8'

services:
  # Aplicação Django
  web:
    build:
      context: .
      dockerfile: Dockerfile.dev
    ports:
      - "8100:8000"
    environment:
      - SECRET_KEY=dev-secret-key-change-in-production
      - DEBUG=True
      - DATABASE_URL=sqlite:///db.sqlite3
      - PYTHONUNBUFFERED=1
    volumes:
      - .:/app
      - static_volume:/app/staticfiles
      - media_volume:/app/media
    working_dir: /app
    command: >
      sh -c "pip install --no-cache-dir -r requirements.txt &&
             python manage.py migrate --noinput &&
             python manage.py collectstatic --noinput &&
             python manage.py runserver 0.0.0.0:8000"
    restart: unless-stopped
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:8000/"]
      interval: 30s
      timeout: 10s
      retries: 3

volumes:
  static_volume:
  media_volume:


