From ff6921b2f4c70b4e1e4d0f6678cf0b28bbc9a382 Mon Sep 17 00:00:00 2001 From: Trey t Date: Wed, 4 Mar 2026 21:23:01 -0600 Subject: [PATCH] Add Docker build args for NEXT_PUBLIC env vars Next.js NEXT_PUBLIC_* variables are baked in at build time, not runtime. Without ARG declarations in the Dockerfile, Dokku's --build-arg flags have no effect and PostHog/API URLs are undefined in the client bundle. Co-Authored-By: Claude Opus 4.6 --- Dockerfile | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Dockerfile b/Dockerfile index 5c333c3..f7b8922 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,6 +7,15 @@ COPY package*.json ./ RUN npm ci COPY . . + +# Next.js NEXT_PUBLIC_* vars must be present at build time +ARG NEXT_PUBLIC_API_URL +ARG NEXT_PUBLIC_POSTHOG_KEY +ARG NEXT_PUBLIC_POSTHOG_HOST +ENV NEXT_PUBLIC_API_URL=$NEXT_PUBLIC_API_URL +ENV NEXT_PUBLIC_POSTHOG_KEY=$NEXT_PUBLIC_POSTHOG_KEY +ENV NEXT_PUBLIC_POSTHOG_HOST=$NEXT_PUBLIC_POSTHOG_HOST + RUN npm run build # Production stage