services:
  app:
    build: .
    ports:
      - "8000:8000"
    environment:
      APP_NAME: "Velora"
      APP_ENV: local
      APP_DEBUG: "true"
      # Clé locale par défaut afin que Docker fonctionne immédiatement.
      # Une valeur APP_KEY définie dans .env reste prioritaire.
      APP_KEY: "${APP_KEY:-base64:vlH33eE0tfW5zStUevcDWInDgWxxb1EfyJ4bKkPXS6g=}"
      DB_CONNECTION: mysql
      DB_HOST: mysql
      DB_PORT: 3306
      DB_DATABASE: epargne
      DB_USERNAME: epargne
      DB_PASSWORD: secret
    depends_on:
      mysql:
        condition: service_healthy
  mysql:
    image: mysql:8.4
    environment:
      MYSQL_DATABASE: epargne
      MYSQL_USER: epargne
      MYSQL_PASSWORD: secret
      MYSQL_ROOT_PASSWORD: root-secret
    volumes:
      - mysql-data:/var/lib/mysql
    healthcheck:
      test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
      interval: 5s
      timeout: 3s
      retries: 20
volumes:
  mysql-data:
