services:
  mysql:
    image: mysql:8.4
    environment:
      MYSQL_ROOT_PASSWORD: root-password
      MYSQL_DATABASE: certificate_system
      MYSQL_USER: certificate
      MYSQL_PASSWORD: certificate
    volumes:
      - mysql-data:/var/lib/mysql
    ports:
      - "${MYSQL_PORT:-3306}:3306"
    healthcheck:
      test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
      interval: 10s
      timeout: 5s
      retries: 5

  backend:
    build:
      context: ./backend
    env_file:
      - .env
    volumes:
      - certificate-data:/data/certificate-system
    depends_on:
      mysql:
        condition: service_healthy
    ports:
      - "${BACKEND_PORT:-8000}:8000"

  frontend:
    build:
      context: ./frontend
    depends_on:
      - backend
    ports:
      - "${FRONTEND_PORT:-8080}:80"

volumes:
  mysql-data:
  certificate-data:
