You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was reviewing changes to the templates to pull in changes into my project, and figured I'd share some of my learnings here as I've been using this Dockerfile template for a while now.
next.config.js is baked at build time :(
Any environment variables used in next.config.js need to be provided at build time, regardless of whether --experimental-build-mode compile is used or not.
This means that any suggested builder, such as a github action, will need to be aware of the NEXT_PUBLIC_SERVER_URL and be able to pass it in:
# Make sure to pass NEXT_PUBLIC_SERVER_URL
- name: Build and Push to container registryuses: docker/build-push-action@v5with:
push: ${{ github.event_name != 'pull_request' }}tags: ${{ env.IMAGE_TAG }}build-args: | NEXT_PUBLIC_SERVER_URL=${{ vars.NEXT_PUBLIC_SERVER_URL }}
Along with a change to the Dockerfile in the build stage
--- a/Dockerfile+++ b/Dockerfile@@ -20,6 +20,8 @@ RUN \
# Rebuild the source code only when needed
FROM base AS builder
+ARG NEXT_PUBLIC_SERVER_URL
I'd recommend adding this line to the website template for sure as the website template's next.config.js references NEXT_PUBLIC_SERVER_URL here
This may also affects VERCEL_PROJECT_PRODUCTION_URL... I'm unfamiliar with Vercel, and whether they own the build process or not.
The text was updated successfully, but these errors were encountered:
I was reviewing changes to the templates to pull in changes into my project, and figured I'd share some of my learnings here as I've been using this Dockerfile template for a while now.
next.config.js
is baked at build time :(Any environment variables used in
next.config.js
need to be provided at build time, regardless of whether--experimental-build-mode compile
is used or not.This means that any suggested builder, such as a github action, will need to be aware of the
NEXT_PUBLIC_SERVER_URL
and be able to pass it in:Along with a change to the Dockerfile in the build stage
I'd recommend adding this line to the website template for sure as the website template's
next.config.js
references NEXT_PUBLIC_SERVER_URL hereThis may also affects
VERCEL_PROJECT_PRODUCTION_URL
... I'm unfamiliar with Vercel, and whether they own the build process or not.The text was updated successfully, but these errors were encountered: