# A4 compatibility server for the ONLYOFFICE Document Server API, with the three editors behind it.
#
# One public port: the compatibility server (8080). Storages (Nextcloud, Seafile, Alfresco, Moodle, ...) are pointed at it
# as if it were "ONLYOFFICE Docs". It proxies the editors by path prefix (/word, /cell, /slide), so the editors never
# face the network themselves; they talk back to it for "who is this" and "give me the file".
#
# FLAG FORM MATTERS: a value is separated by a SPACE, i.e. two list items (`- --word` and the address on the next line).
# The `--word=...` form is silently dropped by the editors' servers.
#
# Editor images are single-platform linux/amd64; their `platform:` lines are mandatory on arm64 hosts.
name: a4-compat

services:
  compat:
    image: a4-compat:2026.4.0.6
    # No `platform:` here: this server ships for both amd64 and arm64 (load the archive for your machine). A pinned
    # platform makes Docker on arm64 refuse the arm64 image it has just loaded.
    restart: unless-stopped
    ports: ["127.0.0.1:8080:8080"]
    environment:
      # Shared secret with the storage: same value in the storage's "secret key" field. Leave empty to run without JWT
      # inside a closed network only.
      JWT_SECRET: "change-me"
    command:
      - --public-url
      - https://office.example.com
      - --word
      - http://word:8090
      - --cell
      - http://cell:8092
      - --slide
      - http://slide:8090

  word:
    image: a4-webhost:latest
    platform: linux/amd64
    restart: unless-stopped
    volumes: ["word-cabins:/data/cabins"]
    command:
      - --base-path
      - /word
      - --max-cabins
      - "12"
      - --idle-min
      - "20"
      - --auth-url
      - http://compat:8080/host/v1/me
      - --attach-url
      - http://compat:8080/host/v1/attachments/{id}/content

  cell:
    image: f1-webhost:latest
    platform: linux/amd64
    restart: unless-stopped
    volumes: ["cell-cabins:/data/cabins"]
    command:
      - --base-path
      - /cell
      - --max-cabins
      - "12"
      - --idle-min
      - "20"
      - --auth-url
      - http://compat:8080/host/v1/me
      - --attach-url
      - http://compat:8080/host/v1/attachments/{id}/content

  slide:
    image: p2-server:latest
    platform: linux/amd64
    restart: unless-stopped
    # The presentations image starts in "folder" mode by default; the external-host mode needs the entrypoint replaced.
    entrypoint: ["node", "/app/slides-server.mjs"]
    command:
      - --host
      - 0.0.0.0
      - --port
      - "8090"
      - --dist
      - /app/dist
      - --base-path
      - /slide
      - --auth-url
      - http://compat:8080/host/v1/me
      - --attach-url
      - http://compat:8080/host/v1/attachments/{id}/content
      - --replace-url
      - http://compat:8080/host/v1/attachments/{id}/replace

volumes:
  word-cabins:
  cell-cabins:

# Checks on the machine itself:
#   curl -s http://127.0.0.1:8080/healthcheck        -> true
#   curl -s http://127.0.0.1:8080/health             -> JSON with "status": "ok" and the connected editors
#   curl -s http://127.0.0.1:8080/word/health        -> the documents editor behind the proxy
