services:
  db:
    image: postgres:16
    environment:
      POSTGRES_DB: opnform_e2e
      POSTGRES_USER: opnform
      POSTGRES_PASSWORD: opnform
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U opnform -d opnform_e2e"]
      interval: 5s
      timeout: 5s
      retries: 20
    ports:
      - "55432:5432"

  api:
    image: jhumanj/opnform-api:dev
    working_dir: /usr/share/nginx/html
    volumes:
      - ./api:/usr/share/nginx/html
    environment:
      APP_ENV: e2e
      APP_DEBUG: "true"
      APP_URL: http://127.0.0.1:8089
      FRONT_URL: http://127.0.0.1:3100
      FRONT_API_SECRET: secret
      APP_KEY: base64:dD8AFEB45nKZ0VWmIPiW495rDYb+ywRJnCCSdycw0pI=
      JWT_SECRET: 38hjE96gYu4ceKSSHNnzgeynMr2m3WkNBN2u7zzpVeiITtxFEloxAjcr7TCKuiiy
      SELF_HOSTED: "false"
      DB_CONNECTION: pgsql
      DB_HOST: db
      DB_PORT: 5432
      DB_DATABASE: opnform_e2e
      DB_USERNAME: opnform
      DB_PASSWORD: opnform
      CACHE_STORE: file
      SESSION_DRIVER: file
      QUEUE_CONNECTION: sync
      FILESYSTEM_DRIVER: local
      LOCAL_FILESYSTEM_VISIBILITY: public
      MAIL_MAILER: log
      MAIL_FROM_ADDRESS: dev@localhost
      MAIL_FROM_NAME: OpnForm-E2E
      PHP_MEMORY_LIMIT: "1G"
      PHP_MAX_EXECUTION_TIME: "600"
      PHP_UPLOAD_MAX_FILESIZE: "64M"
      PHP_POST_MAX_SIZE: "64M"
      APP_DEV_CORS: "true"
    depends_on:
      db:
        condition: service_healthy

  ingress:
    image: nginx:1
    volumes:
      - ./api:/usr/share/nginx/html
      - ./docker/nginx.dev.conf:/etc/nginx/templates/default.conf.template
    environment:
      NGINX_HOST: localhost
      NGINX_PORT: 80
      NGINX_MAX_BODY_SIZE: 64m
    ports:
      - "8089:80"
    depends_on:
      - api
