From cce59e3bf6571bca815920ce0762d89ff41da7d9 Mon Sep 17 00:00:00 2001 From: Victor Santos Date: Fri, 12 Dec 2025 14:00:59 -0300 Subject: [PATCH] refactor: replace CDN_URL with CDN_HOST in Dockerfiles and update related scripts for asset loading --- Dockerfile.fips.standalone-infisical | 10 +++++----- Dockerfile.standalone-infisical | 10 +++++----- frontend/vite.config.ts | 14 +++++++------- standalone-entrypoint.sh | 4 ++-- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/Dockerfile.fips.standalone-infisical b/Dockerfile.fips.standalone-infisical index e1143df1c9..2c7ce04d91 100644 --- a/Dockerfile.fips.standalone-infisical +++ b/Dockerfile.fips.standalone-infisical @@ -2,8 +2,8 @@ ARG POSTHOG_HOST=https://app.posthog.com ARG POSTHOG_API_KEY=posthog-api-key ARG INTERCOM_ID=intercom-id ARG CAPTCHA_SITE_KEY=captcha-site-key -# CDN URL placeholder - replaced at container startup with actual CDN_URL env var -ARG CDN_URL=__INFISICAL_CDN_URL__ +# CDN HOST placeholder - replaced at container startup with actual CDN_HOST env var +ARG CDN_HOST=__INFISICAL_CDN_HOST__ FROM node:20.19.5-trixie-slim AS base @@ -38,8 +38,8 @@ ARG INFISICAL_PLATFORM_VERSION ENV VITE_INFISICAL_PLATFORM_VERSION $INFISICAL_PLATFORM_VERSION ARG CAPTCHA_SITE_KEY ENV VITE_CAPTCHA_SITE_KEY $CAPTCHA_SITE_KEY -ARG CDN_URL -ENV VITE_CDN_URL $CDN_URL +ARG CDN_HOST +ENV VITE_CDN_HOST $CDN_HOST ENV NODE_OPTIONS="--max-old-space-size=8192" @@ -189,7 +189,7 @@ COPY --from=backend-runner /app /backend COPY --from=frontend-runner /app ./backend/frontend-build -# Copy CDN URL replacement script for runtime CDN URL replacement +# Copy CDN HOST replacement script for runtime CDN HOST replacement COPY frontend/scripts/replace-standalone-build-variable.sh /backend/scripts/replace-standalone-build-variable.sh RUN chmod +x /backend/scripts/export-assets.sh /backend/scripts/replace-standalone-build-variable.sh RUN chown -R non-root-user:nodejs /backend/frontend-build diff --git a/Dockerfile.standalone-infisical b/Dockerfile.standalone-infisical index b921becd8b..91b7e78c8b 100644 --- a/Dockerfile.standalone-infisical +++ b/Dockerfile.standalone-infisical @@ -2,8 +2,8 @@ ARG POSTHOG_HOST=https://app.posthog.com ARG POSTHOG_API_KEY=posthog-api-key ARG INTERCOM_ID=intercom-id ARG CAPTCHA_SITE_KEY=captcha-site-key -# CDN URL placeholder - replaced at container startup with actual CDN_URL env var -ARG CDN_URL=__INFISICAL_CDN_URL__ +# CDN HOST placeholder - replaced at container startup with actual CDN_HOST env var +ARG CDN_HOST=__INFISICAL_CDN_HOST__ FROM node:20.19.5-trixie-slim AS base @@ -40,8 +40,8 @@ ENV INFISICAL_PLATFORM_VERSION $INFISICAL_PLATFORM_VERSION ENV VITE_INFISICAL_PLATFORM_VERSION $INFISICAL_PLATFORM_VERSION ARG CAPTCHA_SITE_KEY ENV VITE_CAPTCHA_SITE_KEY $CAPTCHA_SITE_KEY -ARG CDN_URL -ENV VITE_CDN_URL $CDN_URL +ARG CDN_HOST +ENV VITE_CDN_HOST $CDN_HOST ENV NODE_OPTIONS="--max-old-space-size=8192" # Build @@ -178,7 +178,7 @@ ENV CAPTCHA_SITE_KEY=$CAPTCHA_SITE_KEY COPY --from=backend-runner /app /backend COPY --from=frontend-runner /app ./backend/frontend-build -# Copy CDN URL replacement script for runtime CDN URL replacement +# Copy CDN HOST replacement script for runtime CDN HOST replacement COPY frontend/scripts/replace-standalone-build-variable.sh /backend/scripts/replace-standalone-build-variable.sh RUN chmod +x /backend/scripts/export-assets.sh /backend/scripts/replace-standalone-build-variable.sh RUN chown -R non-root-user:nodejs /backend/frontend-build diff --git a/frontend/vite.config.ts b/frontend/vite.config.ts index 52df8dbaab..f847676dba 100644 --- a/frontend/vite.config.ts +++ b/frontend/vite.config.ts @@ -29,11 +29,11 @@ export default defineConfig(({ mode }) => { "0.0.1" ).replaceAll(".", "-"); - // CDN URL for static assets in /assets/* only. - // Docker: Set CDN_URL env var at runtime (placeholder replaced at container startup). - // Direct build: Use --build-arg CDN_URL=https://... or VITE_CDN_URL env var. + // CDN HOST for static assets in /assets/* only. + // Docker: Set CDN_HOST env var at runtime (placeholder replaced at container startup). + // Direct build: Use --build-arg CDN_HOST=https://... or VITE_CDN_HOST env var. // Default: Empty = same-origin asset loading. - const cdnUrl = env.VITE_CDN_URL || ""; + const cdnHost = env.VITE_CDN_HOST || ""; return { base: "/", @@ -60,10 +60,10 @@ export default defineConfig(({ mode }) => { } }, experimental: { - // Only apply CDN URL to files in /assets/* directory + // Only apply CDN HOST to files in /assets/* directory renderBuiltUrl(filename) { - if (filename.startsWith("assets/") && cdnUrl) { - return `${cdnUrl}/${filename}`; + if (filename.startsWith("assets/") && cdnHost) { + return `${cdnHost}/${filename}`; } return `/${filename}`; } diff --git a/standalone-entrypoint.sh b/standalone-entrypoint.sh index 37f0475f58..6ede9a0b88 100755 --- a/standalone-entrypoint.sh +++ b/standalone-entrypoint.sh @@ -5,8 +5,8 @@ update-ca-certificates if [ -d "/backend/frontend-build/assets" ]; then cd /backend/frontend-build || { echo "ERROR: Failed to cd to frontend-build"; exit 1; } - if ! /backend/scripts/replace-standalone-build-variable.sh "__INFISICAL_CDN_URL__" "${CDN_URL:-}"; then - echo "WARNING: CDN URL replacement failed, assets may not load correctly" + if ! /backend/scripts/replace-standalone-build-variable.sh "__INFISICAL_CDN_HOST__" "${CDN_HOST:-}"; then + echo "WARNING: CDN HOST replacement failed, assets may not load correctly" fi cd /backend || { echo "ERROR: Failed to cd to backend"; exit 1; }