[GH-ISSUE #363] migrate NEXT_PUBLIC environment variables to server for supporting docker-image deployment #231

Closed
opened 2026-03-03 11:14:12 +03:00 by kerem · 1 comment
Owner

Originally created by @pavanbhaskardev on GitHub (Jul 25, 2025).
Original GitHub issue: https://github.com/dflow-sh/dflow/issues/363

Problem

  • When we create docker-image of nextjs-app, it'll inject NEXT_PUBLIC variables into js-bundle
  • After creation of docker-image if we give new value for any NEXT_PUBLIC environment variable it won't reflect

Requirements

  • Convert the NEXT_PUBLIC to server environment variables so they can be added dynamically during the build-time
  • Pass the server variables to client-side using React-context-provider

Benifits

  • Self-hosting setup becomes more easy
Originally created by @pavanbhaskardev on GitHub (Jul 25, 2025). Original GitHub issue: https://github.com/dflow-sh/dflow/issues/363 ### Problem - When we create docker-image of nextjs-app, it'll inject NEXT_PUBLIC variables into js-bundle - After creation of docker-image if we give new value for any NEXT_PUBLIC environment variable it won't reflect ### Requirements - Convert the NEXT_PUBLIC to server environment variables so they can be added dynamically during the build-time - Pass the server variables to client-side using [React-context-provider](https://react.dev/reference/react/createContext) ### Benifits - Self-hosting setup becomes more easy
kerem 2026-03-03 11:14:12 +03:00
Author
Owner

@pavanbhaskardev commented on GitHub (Jul 29, 2025):

  1. Found an example in nhost where they're building NEXT_PUBLIC environment variables with static values
# DockerFile
ENV NEXT_PUBLIC_NHOST_ADMIN_SECRET=__NEXT_PUBLIC_NHOST_ADMIN_SECRET__
ENV NEXT_PUBLIC_NHOST_AUTH_URL=__NEXT_PUBLIC_NHOST_AUTH_URL__

ENTRYPOINT ["./docker-entrypoint.sh"]
  1. in docker-entrypoint.sh they're replacing the __NEXT_PUBLIC_NHOST_AUTH_URL__ placehoder values with original values
# replace placeholders
find dashboard -type f -exec sed -i "s~__NEXT_PUBLIC_NHOST_ADMIN_SECRET__~${NEXT_PUBLIC_NHOST_ADMIN_SECRET}~g" {} +
find dashboard -type f -exec sed -i "s~__NEXT_PUBLIC_NHOST_AUTH_URL__~${NEXT_PUBLIC_NHOST_AUTH_URL}~g" {} +
  1. implemented same approach it's working fine!
<!-- gh-comment-id:3131958640 --> @pavanbhaskardev commented on GitHub (Jul 29, 2025): 1. Found an example in [nhost](https://github.com/nhost/nhost/tree/main) where they're building NEXT_PUBLIC environment variables with static values ```bash # DockerFile ENV NEXT_PUBLIC_NHOST_ADMIN_SECRET=__NEXT_PUBLIC_NHOST_ADMIN_SECRET__ ENV NEXT_PUBLIC_NHOST_AUTH_URL=__NEXT_PUBLIC_NHOST_AUTH_URL__ ENTRYPOINT ["./docker-entrypoint.sh"] ``` 2. in `docker-entrypoint.sh` they're replacing the `__NEXT_PUBLIC_NHOST_AUTH_URL__` placehoder values with original values ```bash # replace placeholders find dashboard -type f -exec sed -i "s~__NEXT_PUBLIC_NHOST_ADMIN_SECRET__~${NEXT_PUBLIC_NHOST_ADMIN_SECRET}~g" {} + find dashboard -type f -exec sed -i "s~__NEXT_PUBLIC_NHOST_AUTH_URL__~${NEXT_PUBLIC_NHOST_AUTH_URL}~g" {} + ``` 3. implemented same approach it's working fine!
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/dflow#231
No description provided.