services:
  mysql:
    image: mysql:8.0
    container_name: bottle_ai_mysql
    restart: unless-stopped
    environment:
      MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD:-rootpassword}
      MYSQL_DATABASE: ${MYSQL_DATABASE:-bottle_ai}
      MYSQL_USER: ${MYSQL_USER:-bottle}
      MYSQL_PASSWORD: ${MYSQL_PASSWORD:-bottlepass}
    ports:
      - "3306:3306"
    volumes:
      - mysql_data:/var/lib/mysql
    healthcheck:
      test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-uroot", "-prootpassword"]
      interval: 5s
      timeout: 5s
      retries: 20

  backend:
    build:
      context: .
      dockerfile: docker/Dockerfile.backend
    container_name: bottle_ai_backend
    restart: unless-stopped
    env_file:
      - .env
    environment:
      DATABASE_URL: mysql+pymysql://${MYSQL_USER:-bottle}:${MYSQL_PASSWORD:-bottlepass}@mysql:3306/${MYSQL_DATABASE:-bottle_ai}
    ports:
      - "8000:8000"
    volumes:
      - ./backend/static:/app/static
      - ./backend/app:/app/app
    depends_on:
      mysql:
        condition: service_healthy

volumes:
  mysql_data:
