Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: nextjs runtime read env var #5

Merged
merged 1 commit into from
Aug 14, 2022
Merged

feat: nextjs runtime read env var #5

merged 1 commit into from
Aug 14, 2022

Conversation

sljeff
Copy link
Contributor

@sljeff sljeff commented Aug 14, 2022

  • The nextjs env var can only be set at build time. And it replaces process.env so env var can't be read at runtime. The disadvantages are:
    • Each build-arg need to be specified when building
    • The image (which is public) will have these variable values
    • If you have multiple environments (e.g. development), you need to compile multiple images (with diff tags)
  • So this entrypoint.sh will read the environment variables and replace the nextjs compiled file

issue:
vercel/next.js#17641

https://raphaelpralat.medium.com/system-environment-variables-in-next-js-with-docker-1f0754e04cde

@vercel
Copy link

vercel bot commented Aug 14, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
xlog ✅ Ready (Inspect) Visit Preview Aug 14, 2022 at 3:48AM (UTC)

@sljeff sljeff merged commit 21a2659 into dev Aug 14, 2022
@sljeff sljeff deleted the feat-runtime-env branch August 14, 2022 03:49
zsakvo pushed a commit to zsakvo/xLog that referenced this pull request Apr 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant