# Inference Co-op LibreChat — brand overlay on the official Cloudron package
#
# Build:  cloudron builder build --repository registry.inference.coop/co-op/librechat-custom --tag <yyyymmdd>-<gitsha>
# Deploy: cloudron update --app <app-id> --image registry.inference.coop/co-op/librechat-custom:<tag>
#         (run from THIS directory — the CLI reads CloudronManifest.json here)
#
# Rules that keep this image safe:
#   1. The base tag is PINNED to the exact appstore image the app runs
#      (manifest.dockerImage). Never a floating tag: a rebuild must never
#      silently pull a newer LibreChat than the one we validated.
#   2. NEVER edit CloudronManifest.json — the copy in this repo must stay
#      byte-identical to the OFFICIAL appstore manifest. `cloudron update`
#      reads it from the deploy directory and applies it to the app; a
#      hand-edited manifest that omits addons (postgresql, mongodb, oidc,
#      sendmail, localstorage) strips them from the app and crash-loops it
#      (mkdir: Read-only file system). That is what broke the sandbox on
#      2026-10-18 — the manifest, not the overlay, was the bug.
#   3. This image changes ONLY static brand assets. All behavior lives on the
#      persistent volume (/app/data/librechat.yaml, /app/data/env,
#      /app/data/mcp/) and survives image updates unchanged.
FROM cloudron/ai.librechat.cloudronapp:202610150224320000

# Login-page + header logo (the client bundle references assets/logo.svg)
COPY assets/logo.svg /app/code/librechat/client/dist/assets/logo.svg
# Browser favicons + PWA icons (referenced by dist/index.html + manifest.webmanifest)
COPY assets/favicon-32x32.png /app/code/librechat/client/dist/assets/favicon-32x32.png
COPY assets/favicon-16x16.png /app/code/librechat/client/dist/assets/favicon-16x16.png
COPY assets/apple-touch-icon-180x180.png /app/code/librechat/client/dist/assets/apple-touch-icon-180x180.png
COPY assets/icon-192x192.png /app/code/librechat/client/dist/assets/icon-192x192.png
COPY assets/maskable-icon.png /app/code/librechat/client/dist/assets/maskable-icon.png

# Copy custom branding CSS
COPY assets/custom.css /app/code/librechat/client/dist/assets/custom.css
# Insert the CSS link after the title tag
RUN sed -i '/<title>Inference Co-op<\/title>/a <link rel="stylesheet" href="assets/custom.css">' /app/code/librechat/client/dist/index.html

# Browser-tab title (index.html is baked at build; sed no-ops harmlessly if
# the upstream markup ever changes)
RUN sed -i 's|<title>LibreChat</title>|<title>Inference Co-op</title>|' /app/code/librechat/client/dist/index.html && \
    sed -i '/<title>Inference Co-op<\/title>/a <link rel="stylesheet" href="assets/custom.css">' /app/code/librechat/client/dist/index.html
