services:
  gotenberg:
    image: ${DOCKER_REGISTRY}/${DOCKER_REPOSITORY}:${GOTENBERG_VERSION}
    ports:
      - "${API_PORT}:${API_PORT}"
    environment:
      GOTENBERG_API_BASIC_AUTH_USERNAME: ${GOTENBERG_API_BASIC_AUTH_USERNAME}
      GOTENBERG_API_BASIC_AUTH_PASSWORD: ${GOTENBERG_API_BASIC_AUTH_PASSWORD}
      OTEL_SERVICE_NAME: ${OTEL_SERVICE_NAME}
      OTEL_TRACES_EXPORTER: ${OTEL_TRACES_EXPORTER}
      OTEL_METRICS_EXPORTER: ${OTEL_METRICS_EXPORTER}
      OTEL_LOGS_EXPORTER: ${OTEL_LOGS_EXPORTER}
      OTEL_EXPORTER_OTLP_PROTOCOL: ${OTEL_EXPORTER_OTLP_PROTOCOL}
      OTEL_EXPORTER_OTLP_ENDPOINT: ${OTEL_EXPORTER_OTLP_ENDPOINT}
      OTEL_EXPORTER_OTLP_INSECURE: ${OTEL_EXPORTER_OTLP_INSECURE}
    command:
      - "gotenberg"
      - "--gotenberg-hide-banner=${GOTENBERG_HIDE_BANNER}"
      - "--gotenberg-graceful-shutdown-duration=${GOTENBERG_GRACEFUL_SHUTDOWN_DURATION}"
      - "--gotenberg-build-debug-data=${GOTENBERG_BUILD_DEBUG_DATA}"
      - "--api-port=${API_PORT}"
      - "--api-port-from-env=${API_PORT_FROM_ENV}"
      - "--api-bind-ip=${API_BIND_IP}"
      - "--api-start-timeout=${API_START_TIMEOUT}"
      - "--api-timeout=${API_TIMEOUT}"
      - "--api-body-limit=${API_BODY_LIMIT}"
      - "--api-root-path=${API_ROOT_PATH}"
      - "--api-correlation-id-header=${API_CORRELATION_ID_HEADER}"
      - "--api-enable-basic-auth=${API_ENABLE_BASIC_AUTH}"
      - "--api-download-from-allow-list=${API_DOWNLOAD_FROM_ALLOW_LIST}"
      - "--api-download-from-deny-list=${API_DOWNLOAD_FROM_DENY_LIST}"
      - "--api-download-from-max-retry=${API_DOWNLOAD_FROM_MAX_RETRY}"
      - "--api-disable-download-from=${API_DISABLE_DOWNLOAD_FROM}"
      - "--api-disable-health-check-route-telemetry=${API_DISABLE_HEALTH_CHECK_ROUTE_TELEMETRY}"
      - "--api-disable-root-route-telemetry=${API_DISABLE_ROOT_ROUTE_TELEMETRY}"
      - "--api-disable-debug-route-telemetry=${API_DISABLE_DEBUG_ROUTE_TELEMETRY}"
      - "--api-disable-version-route-telemetry=${API_DISABLE_VERSION_ROUTE_TELEMETRY}"
      - "--api-enable-debug-route=${API_ENABLE_DEBUG_ROUTE}"
      - "--chromium-restart-after=${CHROMIUM_RESTART_AFTER}"
      - "--chromium-auto-start=${CHROMIUM_AUTO_START}"
      - "--chromium-max-queue-size=${CHROMIUM_MAX_QUEUE_SIZE}"
      - "--chromium-idle-shutdown-timeout=${CHROMIUM_IDLE_SHUTDOWN_TIMEOUT}"
      - "--chromium-max-concurrency=${CHROMIUM_MAX_CONCURRENCY}"
      - "--chromium-start-timeout=${CHROMIUM_START_TIMEOUT}"
      - "--chromium-allow-insecure-localhost=${CHROMIUM_ALLOW_INSECURE_LOCALHOST}"
      - "--chromium-ignore-certificate-errors=${CHROMIUM_IGNORE_CERTIFICATE_ERRORS}"
      - "--chromium-disable-web-security=${CHROMIUM_DISABLE_WEB_SECURITY}"
      - "--chromium-allow-file-access-from-files=${CHROMIUM_ALLOW_FILE_ACCESS_FROM_FILES}"
      - "--chromium-host-resolver-rules=${CHROMIUM_HOST_RESOLVER_RULES}"
      - "--chromium-proxy-server=${CHROMIUM_PROXY_SERVER}"
      - "--chromium-allow-list=${CHROMIUM_ALLOW_LIST}"
      - "--chromium-deny-list=${CHROMIUM_DENY_LIST}"
      - "--chromium-clear-cache=${CHROMIUM_CLEAR_CACHE}"
      - "--chromium-clear-cookies=${CHROMIUM_CLEAR_COOKIES}"
      - "--chromium-disable-javascript=${CHROMIUM_DISABLE_JAVASCRIPT}"
      - "--chromium-disable-routes=${CHROMIUM_DISABLE_ROUTES}"
      - "--libreoffice-restart-after=${LIBREOFFICE_RESTART_AFTER}"
      - "--libreoffice-max-queue-size=${LIBREOFFICE_MAX_QUEUE_SIZE}"
      - "--libreoffice-idle-shutdown-timeout=${LIBREOFFICE_IDLE_SHUTDOWN_TIMEOUT}"
      - "--libreoffice-auto-start=${LIBREOFFICE_AUTO_START}"
      - "--libreoffice-start-timeout=${LIBREOFFICE_START_TIMEOUT}"
      - "--libreoffice-allow-list=${LIBREOFFICE_ALLOW_LIST}"
      - "--libreoffice-deny-list=${LIBREOFFICE_DENY_LIST}"
      - "--libreoffice-disable-routes=${LIBREOFFICE_DISABLE_ROUTES}"
      - "--log-level=${LOG_LEVEL}"
      - "--log-fields-prefix=${LOG_FIELDS_PREFIX}"
      - "--log-std-format=${LOG_STD_FORMAT}"
      - "--log-std-enable-gcp-fields=${LOG_STD_ENABLE_GCP_FIELDS}"
      - "--pdfengines-merge-engines=${PDFENGINES_MERGE_ENGINES}"
      - "--pdfengines-split-engines=${PDFENGINES_SPLIT_ENGINES}"
      - "--pdfengines-flatten-engines=${PDFENGINES_FLATTEN_ENGINES}"
      - "--pdfengines-convert-engines=${PDFENGINES_CONVERT_ENGINES}"
      - "--pdfengines-read-metadata-engines=${PDFENGINES_READ_METADATA_ENGINES}"
      - "--pdfengines-write-metadata-engines=${PDFENGINES_WRITE_METADATA_ENGINES}"
      - "--pdfengines-read-bookmarks-engines=${PDFENGINES_READ_BOOKMARKS_ENGINES}"
      - "--pdfengines-write-bookmarks-engines=${PDFENGINES_WRITE_BOOKMARKS_ENGINES}"
      - "--pdfengines-watermark-engines=${PDFENGINES_WATERMARK_ENGINES}"
      - "--pdfengines-stamp-engines=${PDFENGINES_STAMP_ENGINES}"
      - "--pdfengines-encrypt-engines=${PDFENGINES_ENCRYPT_ENGINES}"
      - "--pdfengines-rotate-engines=${PDFENGINES_ROTATE_ENGINES}"
      - "--pdfengines-embed-engines=${PDFENGINES_EMBED_ENGINES}"
      - "--pdfengines-embed-metadata-engines=${PDFENGINES_EMBED_METADATA_ENGINES}"
      - "--pdfengines-disable-routes=${PDFENGINES_DISABLE_ROUTES}"
      - "--prometheus-namespace=${PROMETHEUS_NAMESPACE}"
      - "--prometheus-collect-interval=${PROMETHEUS_COLLECT_INTERVAL}"
      - "--prometheus-disable-route-telemetry=${PROMETHEUS_DISABLE_ROUTE_TELEMETRY}"
      - "--prometheus-disable-collect=${PROMETHEUS_DISABLE_COLLECT}"
      - "--prometheus-metrics-path=${PROMETHEUS_METRICS_PATH}"
      - "--webhook-enable-sync-mode=${WEBHOOK_ENABLE_SYNC_MODE}"
      - "--webhook-allow-list=${WEBHOOK_ALLOW_LIST}"
      - "--webhook-deny-list=${WEBHOOK_DENY_LIST}"
      - "--webhook-max-retry=${WEBHOOK_MAX_RETRY}"
      - "--webhook-retry-min-wait=${WEBHOOK_RETRY_MIN_WAIT}"
      - "--webhook-retry-max-wait=${WEBHOOK_RETRY_MAX_WAIT}"
      - "--webhook-client-timeout=${WEBHOOK_CLIENT_TIMEOUT}"
      - "--webhook-disable=${WEBHOOK_DISABLE}"

  otel-collector:
    image: otel/opentelemetry-collector-contrib:latest
    command: ["--config=/etc/otel-collector-config.yaml"]
    volumes:
      - ./otel-collector-config.yaml:/etc/otel-collector-config.yaml
    ports:
      - "4317:4317" # OTLP gRPC receiver
    depends_on:
      openobserve:
        condition: service_started
    restart: on-failure

  openobserve:
    image: public.ecr.aws/zinclabs/openobserve:latest
    restart: always
    ports:
      - "5080:5080"
      - "5081:5081"
    environment:
      ZO_ROOT_USER_EMAIL: telemetry@gotenberg.dev
      ZO_ROOT_USER_PASSWORD: telemetry

networks:
  default:
    enable_ipv6: false
