services:
  php:
    container_name: php-${DOCKER_APP_NAME}-fpm
    build:
      context: ./infra/dev
      dockerfile: Dockerfile
      args:
        DOCKER_PHP_VERSION: ${DOCKER_PHP_VERSION}
        DOCKER_NODE_VERSION: ${DOCKER_NODE_VERSION}
        CURRENT_UID: ${CURRENT_UID}
        CURRENT_GID: ${CURRENT_GID}
    environment:
      PHP_IDE_CONFIG: serverName=${DOCKER_APP_NAME}-docker
      XDEBUG_CLIENT_HOST: ${XDEBUG_CLIENT_HOST:-host.docker.internal}
      XDEBUG_CONFIG: client_host=${XDEBUG_CLIENT_HOST:-host.docker.internal} client_port=9003
      DATABASE_URL: "postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@db:${POSTGRES_PORT}/${POSTGRES_DB}?serverVersion=16&charset=utf8"
      COMPOSER_HOME: /tmp/composer
      COMPOSER_CACHE_DIR: /tmp/composer/cache
    volumes:
      - ./:/var/www/html
      - ~/.cache:/var/www/.cache # Pour la cache de composer
      - ~/.config:/var/www/.config # Pour la config de yarn
      - ~/.composer:/var/www/.composer # Pour la config de composer
      - ./infra/dev/php.ini:/usr/local/etc/php/php.ini
      - ./infra/dev/xdebug.ini:/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
      - ./LOG:/var/www/html/LOG
      - uploads_data:/var/www/html/var/uploads
    extra_hosts:
      - "host.docker.internal:host-gateway"
    depends_on:
      - db
    ports:
        - "3002:3002"
    restart: unless-stopped
  nginx:
    image: nginx:1.27-alpine
    container_name: nginx-${DOCKER_APP_NAME}
    depends_on:
      - php
    ports:
      - "8082:80"
    volumes:
      - ./:/var/www/html:ro
      - ./infra/dev/nginx.conf:/etc/nginx/conf.d/default.conf:ro
    restart: unless-stopped
  db:
    image: postgres:16-alpine
    command: -p ${POSTGRES_PORT:-5435}
    environment:
      POSTGRES_DB: ${POSTGRES_DB}
      POSTGRES_USER: ${POSTGRES_USER}
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
    volumes:
      - pg_data:/var/lib/postgresql/data
    ports:
      - "${POSTGRES_PORT:-5435}:${POSTGRES_PORT:-5435}"
    restart: unless-stopped
volumes:
  pg_data:
  uploads_data:
