services:
  db:
    image: mysql:8.0
    container_name: petshop-db
    environment:
      MYSQL_ROOT_PASSWORD: root
      MYSQL_DATABASE: Petstoredb
      MYSQL_USER: petshop
      MYSQL_PASSWORD: petshop
    ports:
      - "3306:3306"
    volumes:
      - db_data:/var/lib/mysql
    healthcheck:
      test: ["CMD", "mysqladmin", "ping", "-h", "127.0.0.1", "-uroot", "-proot"]
      interval: 5s
      timeout: 5s
      retries: 30

  api:
    build: .
    container_name: petshop-api
    environment:
      SPRING_DATASOURCE_URL: jdbc:mysql://db:3306/Petstoredb?useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=UTC
      SPRING_DATASOURCE_USERNAME: petshop
      SPRING_DATASOURCE_PASSWORD: petshop
      # Change this in real use (must be at least 32 characters)
      JWT_SECRET: change_me_please_this_secret_key_is_long_enough_for_jwt_hmac_sha256
      STRIPE_SECRET_KEY: ${STRIPE_SECRET_KEY}
      NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY: ${NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY}
      OPENROUTER_API_KEY: ${OPENROUTER_API_KEY}
      OPENROUTER_MODEL: ${OPENROUTER_MODEL:-openai/gpt-oss-120b:free}
    ports:
      - "8080:8080"
    depends_on:
      db:
        condition: service_healthy

volumes:
  db_data:
