# yaml-language-server: $schema=https://schema.zeabur.app/template.json
apiVersion: zeabur.com/v1
kind: Template
metadata:
    name: LaTeX Worker
spec:
    description: XeLaTeX background worker for Supabase compilation jobs.
    icon: https://upload.wikimedia.org/wikipedia/commons/9/92/LaTeX_logo.svg
    variables:
        - key: PUBLIC_DOMAIN
          type: DOMAIN
          name: Public Domain
          description: Public domain for the worker health endpoint.
        - key: SUPABASE_URL
          type: STRING
          name: Supabase URL
          description: Supabase project URL used by the worker.
        - key: SUPABASE_SERVICE_KEY
          type: PASSWORD
          name: Supabase Service Role Key
          description: Service role key used to claim jobs and upload PDFs.
        - key: SUPABASE_STORAGE_BUCKET
          type: STRING
          name: Supabase Storage Bucket
          description: Public bucket name used to store compiled PDFs.
    tags:
        - Tool
        - PDF
        - Worker
    readme: |-
        # LaTeX Worker

        This template deploys the ExamTK XeLaTeX worker on Zeabur.

        ## What it does

        - Polls `compilation_jobs` from Supabase
        - Renders LaTeX templates and compiles PDFs with XeLaTeX
        - Uploads the result to Supabase Storage by default
        - Supports Tencent COS when those variables are provided separately
        - Exposes `/health` for runtime checks

        ## Required variables

        - `SUPABASE_URL`
        - `SUPABASE_SERVICE_KEY`
        - `SUPABASE_STORAGE_BUCKET` (default: `compiled-pdfs`)

        ## Auto deploy

        This template deploys the current prebuilt image for `latex-worker`.
        For continuous deployment from GitHub, use the repository workflow after import.
    services:
        - name: latex-worker
          icon: https://upload.wikimedia.org/wikipedia/commons/9/92/LaTeX_logo.svg
          template: PREBUILT
          spec:
            source:
                image: registry-oci.zeabur.cloud/e-69d75cc6474db8a99d6ddfbb/s-69d75cdc86ea5714a4e4b3ef:d-69d76794668371c2e5a24e3d
            ports:
                - id: web
                  port: 8080
                  type: HTTP
            env:
                COMPILE_TIMEOUT_MS:
                    default: "120000"
                    expose: false
                POLL_INTERVAL_MS:
                    default: "3000"
                    expose: false
                PORT:
                    default: ${WEB_PORT}
                    expose: false
                SUPABASE_SERVICE_KEY:
                    default: ${SUPABASE_SERVICE_KEY}
                    expose: false
                SUPABASE_STORAGE_BUCKET:
                    default: ${SUPABASE_STORAGE_BUCKET}
                    expose: false
                SUPABASE_URL:
                    default: ${SUPABASE_URL}
                    expose: false
                WORKER_CONCURRENCY:
                    default: "2"
                    expose: false
            healthCheck:
                type: HTTP
                port: web
                http:
                    path: /health
          domainKey: PUBLIC_DOMAIN
