# Atlas's de-branded ONLYOFFICE Document Server.
#
# ONLYOFFICE's own Docker-DocumentServer build does not compile from source —
# it downloads a prebuilt .deb and installs it (see README.md for why we
# don't recompile core/sdkjs/web-apps ourselves). This Dockerfile instead
# patches the already-compiled files inside the official image: the files
# under overlay/ are unmodified-vs-upstream (see git history — first commit
# per file is the pristine baseline, second is Atlas's diff) except for the
# branding removal described in README.md.
#
# nginx in this image serves precompressed .gz siblings (gzip_static on) for
# any file that has one, so every patched file's .gz sibling must be
# regenerated after copying or nginx will keep serving the stale original.

# Pinned to the exact image digest running on atlas-office01/02 as of
# 2026-09-13 (package version 9.4.0-129; the image was pulled as `:latest`,
# which is not itself reproducible, so we pin the resolved digest instead).
ARG BASE_DIGEST=sha256:3ab6ebc7c605e5a32b7ae3ff19daed4925090245acc8100ce2230bd766c88212
FROM onlyoffice/documentserver@${BASE_DIGEST}

COPY overlay/apps /var/www/onlyoffice/documentserver/web-apps/apps

RUN set -eux; \
    cd /var/www/onlyoffice/documentserver/web-apps; \
    for f in \
      apps/documenteditor/main/index.html \
      apps/spreadsheeteditor/main/index.html \
      apps/presentationeditor/main/index.html \
      apps/pdfeditor/main/index.html \
      apps/common/index.html \
      apps/common/main/lib/view/About.js \
      apps/common/main/resources/img/header/header-logo_s.svg \
      apps/common/main/resources/img/header/dark-logo_s.svg \
      apps/common/main/resources/img/about/logo_s.svg \
      apps/common/main/resources/img/about/logo-white_s.svg \
    ; do \
      gzip -9 -f -k "$f"; \
      chown ds:ds "$f" "$f.gz"; \
      chmod 444 "$f" "$f.gz"; \
    done
