somratpro Claude Sonnet 4.6 commited on
Commit
fd4cae0
·
1 Parent(s): bb56821

fix: patch google font → local at runtime to survive cached Stage 1

Browse files

Stage 1 Docker image may be cached from before the font patch was added.
Apply the patch in start.sh at container start (idempotent grep check)
so the cached image is fixed without requiring a full Stage 1 rebuild.

- Dockerfile Stage 2: COPY vendor fonts + patch script to /opt/vendor/
- start.sh: patch layout.tsx files before next build if still on google font

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

Files changed (2) hide show
  1. Dockerfile +10 -0
  2. start.sh +18 -1
Dockerfile CHANGED
@@ -179,6 +179,16 @@ COPY cloudflare-proxy-setup.py /opt/cloudflare-proxy-setup.py
179
  COPY cloudflare-worker.js /opt/cloudflare-worker.js
180
  COPY setup-uptimerobot.sh /opt/setup-uptimerobot.sh
181
 
 
 
 
 
 
 
 
 
 
 
182
  RUN chmod +x /opt/start.sh /opt/setup-uptimerobot.sh
183
 
184
  EXPOSE 7860
 
179
  COPY cloudflare-worker.js /opt/cloudflare-worker.js
180
  COPY setup-uptimerobot.sh /opt/setup-uptimerobot.sh
181
 
182
+ # Vendor fonts + patch script available at runtime.
183
+ # Stage 1 may be cached from before the font patch was added; start.sh applies
184
+ # the patch at container start if layout.tsx still imports next/font/google.
185
+ COPY vendor/fonts/PlusJakartaSans-500-normal.woff2 \
186
+ vendor/fonts/PlusJakartaSans-500-italic.woff2 \
187
+ vendor/fonts/PlusJakartaSans-600-normal.woff2 \
188
+ vendor/fonts/PlusJakartaSans-600-italic.woff2 \
189
+ /opt/vendor/fonts/
190
+ COPY vendor/patch-jakarta-font.js /opt/vendor/patch-jakarta-font.js
191
+
192
  RUN chmod +x /opt/start.sh /opt/setup-uptimerobot.sh
193
 
194
  EXPOSE 7860
start.sh CHANGED
@@ -102,7 +102,7 @@ echo "Dashboard : ${PUBLIC_URL}/"
102
  echo "Postiz UI : ${PUBLIC_URL}/app/"
103
  echo "Postiz API : ${PUBLIC_URL}/app/api/"
104
  echo "Sync every : ${SYNC_INTERVAL}s"
105
- echo "HF backup : ${HF_TOKEN:+enabled}${HF_TOKEN:-disabled (no HF_TOKEN)}"
106
  echo ""
107
 
108
  # ── Postgres ─────────────────────────────────────────────────────────────────
@@ -169,6 +169,23 @@ else
169
  echo " Add HF_TOKEN as a Space secret to enable DB+uploads backup."
170
  fi
171
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
172
  # ── Build Next.js frontend (first boot or after next.config.js change) ───────
173
  # next build is NOT run during docker build — the HF builder's ~4 GB cgroup
174
  # limit is less than what next build needs. We run it here where the runtime
 
102
  echo "Postiz UI : ${PUBLIC_URL}/app/"
103
  echo "Postiz API : ${PUBLIC_URL}/app/api/"
104
  echo "Sync every : ${SYNC_INTERVAL}s"
105
+ echo "HF backup : $([ -n "${HF_TOKEN:-}" ] && echo 'enabled' || echo 'disabled (no HF_TOKEN)')"
106
  echo ""
107
 
108
  # ── Postgres ─────────────────────────────────────────────────────────────────
 
169
  echo " Add HF_TOKEN as a Space secret to enable DB+uploads backup."
170
  fi
171
 
172
+ # ── Patch next/font/google → next/font/local (runtime safety net) ────────────
173
+ # Docker Stage 1 may be cached from before this patch was introduced.
174
+ # Apply here unconditionally so the cached image is fixed at container start.
175
+ # No-op if layout.tsx already uses next/font/local (idempotent grep check).
176
+ _APP_LAYOUT="${POSTIZ_DIR}/apps/frontend/src/app/(app)/layout.tsx"
177
+ if grep -q "next/font/google" "${_APP_LAYOUT}" 2>/dev/null; then
178
+ echo "Patching next/font/google → next/font/local (cached image lacks build-time patch)..."
179
+ mkdir -p "${POSTIZ_DIR}/apps/frontend/src/fonts"
180
+ cp /opt/vendor/fonts/*.woff2 "${POSTIZ_DIR}/apps/frontend/src/fonts/"
181
+ cd "${POSTIZ_DIR}"
182
+ node /opt/vendor/patch-jakarta-font.js
183
+ cd /
184
+ echo "Font patch applied."
185
+ else
186
+ echo "Font patch: layout.tsx already uses next/font/local — skipping."
187
+ fi
188
+
189
  # ── Build Next.js frontend (first boot or after next.config.js change) ───────
190
  # next build is NOT run during docker build — the HF builder's ~4 GB cgroup
191
  # limit is less than what next build needs. We run it here where the runtime