services:
  starter-api:
    image: gitea.leonmorival.com/leon-morival/laravel-starter:latest
    container_name: starter-starter-api-1
    restart: unless-stopped
    depends_on:
      pgsql:
        condition: service_healthy
    # ports: <--- Supprimé pour la sécurité, NPM s'en occupe
    #  - "8002:80"
    environment:
      APP_ENV: "production"
      APP_KEY: "${APP_KEY}"
      APP_URL: "${APP_URL}"
      SERVER_NAME: ":80"
      APP_RUNTIME: "Laravel\\FrankenPHP\\Runtime" # <-- AJOUTÉ pour FrankenPHP
      APP_DEBUG: "true"
      FILESYSTEM_DISK: "public"
      DB_CONNECTION: "pgsql"
      DB_HOST: "pgsql"
      DB_PORT: 5432
      DB_DATABASE: "${DB_DATABASE}"
      DB_USERNAME: "${DB_USERNAME}"
      DB_PASSWORD: "${DB_PASSWORD}"
    volumes:
      - storage-data:/var/www/html/storage/app
      - storage-public-data:/var/www/html/storage/app/public
    networks:
      - nginx
      - internal

  pgsql:
    image: postgres:15-alpine
    container_name: starter-pgsql-1
    restart: unless-stopped
    environment:
      POSTGRES_DB: "${DB_DATABASE}"
      POSTGRES_USER: "${DB_USERNAME}"
      POSTGRES_PASSWORD: "${DB_PASSWORD}"
    volumes:
      - pgsql-data:/var/lib/postgresql/data
    # ports: <--- Tu peux aussi le supprimer si tu n'as pas besoin d'y accéder depuis ton PC (DBeaver/TablePlus)
    #  - "5428:5432"
    healthcheck:
      test: [ "CMD-SHELL", "pg_isready -U ${DB_USERNAME} -d ${DB_DATABASE}" ]
      interval: 5s
      timeout: 5s
      retries: 10
    networks:
      - internal

volumes:
  pgsql-data:
    external: true
    name: starter_pgsql_data
  storage-data:
  storage-public-data:
    name: starter_storage_public_data

networks:
  nginx:
    external: true
  internal:
    driver: bridge
