services:
  db:
    image: mysql:8.4
    restart: unless-stopped
    environment:
      MYSQL_DATABASE: kanban_app
      MYSQL_USER: kanban
      MYSQL_PASSWORD: ${MYSQL_PASSWORD:-kanban-change-me}
      MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD:-root-change-me}
    volumes:
      - mysql_data:/var/lib/mysql
      - ./db/schema.sql:/docker-entrypoint-initdb.d/01-schema.sql:ro
    healthcheck:
      test: ["CMD-SHELL", "mysqladmin ping -h 127.0.0.1 -u$$MYSQL_USER -p$$MYSQL_PASSWORD --silent"]
      interval: 5s
      timeout: 5s
      retries: 20
      start_period: 20s

  app:
    build:
      context: .
      dockerfile: Dockerfile
    restart: unless-stopped
    depends_on:
      db:
        condition: service_healthy
    environment:
      DATABASE_URL: mysql+pymysql://kanban:${MYSQL_PASSWORD:-kanban-change-me}@db:3306/kanban_app
      SECRET_KEY: ${SECRET_KEY:-replace-this-secret-key}
      SMTP_HOST: ${SMTP_HOST:-}
      SMTP_PORT: ${SMTP_PORT:-25}
      SMTP_USER: ${SMTP_USER:-}
      SMTP_PASSWORD: ${SMTP_PASSWORD:-}
      SMTP_FROM: ${SMTP_FROM:-}
      SMTP_USE_TLS: ${SMTP_USE_TLS:-false}
      ADMIN_USERNAME: ${ADMIN_USERNAME:-admin}
      ADMIN_EMAIL: ${ADMIN_EMAIL:-admin@example.com}
      ADMIN_PASSWORD: ${ADMIN_PASSWORD:-replace-this-admin-password}
    ports:
      - "${APP_PORT:-8000}:8000"
    volumes:
      - profile_uploads:/app/app/static/uploads/profiles

volumes:
  mysql_data:
  profile_uploads:
