services:
  db:
    image: mysql:8.0
    container_name: amwal_db
    env_file:
      - .env.docker
    command: --default-authentication-plugin=mysql_native_password
    volumes:
      - mysql_data:/var/lib/mysql
    healthcheck:
      test: ["CMD-SHELL", "mysqladmin ping -h 127.0.0.1 -u$$MYSQL_USER -p$$MYSQL_PASSWORD --silent"]
      interval: 10s
      timeout: 5s
      retries: 12
      start_period: 20s
    restart: unless-stopped

  web:
    build:
      context: .
      dockerfile: Dockerfile
    container_name: amwal_web
    ports:
      - "${APP_PORT:-8080}:8000"
    env_file:
      - .env.docker
    depends_on:
      db:
        condition: service_healthy
    command: gunicorn amwal.wsgi:application --bind 0.0.0.0:8000
    restart: unless-stopped

volumes:
  mysql_data:
