# Development environment override
services:
  nginx:
    build:
      context: .docker/nginx
      target: nginx_dev
    hostname: ${APP_HOST}
    environment:
      - COMPOSE_PROJECT_NAME=${COMPOSE_PROJECT_NAME}
      - APP_HOST=${APP_HOST}
      - NGINX_SERVER_NAME=${NGINX_SERVER_NAME}
    volumes:
      - .:/app
      - ./.docker/certbot/www:/var/www/certbot/:ro
      - ./.docker/certbot/conf/:/etc/nginx/ssl/:ro
    networks:
      - web
    extra_hosts:
      - "host.docker.internal:host-gateway"
    labels:
      - traefik.enable=true
      - traefik.http.routers.web-http-${COMPOSE_PROJECT_NAME}.rule=Host(`${APP_HOST:-test-app.loc}`)
      - traefik.http.routers.web-https-${COMPOSE_PROJECT_NAME}.rule=Host(`${APP_HOST:-test-app.loc}`)
      - traefik.http.routers.web-https-${COMPOSE_PROJECT_NAME}.tls=true

  mariadb:
    networks:
      - web

  php-fpm:
    build:
      target: php_dev
    volumes:
      - .:/app
    labels:
      ofelia.enabled: "true"
      ofelia.job-exec.php-cli.schedule: "@every 1m"
      ofelia.job-exec.php-cli.user: www-data
      ofelia.job-exec.php-cli.command: "php /app/system/cron.php"

networks:
  web:
    name: traefik_default
    external: true
