-
Notifications
You must be signed in to change notification settings - Fork 30.2k
Description
Describe the feature you'd like to request
When dealing with Docker based deployments on different environments, it's very useful to be able to specify environment variables for thinks like the base url for api calls, or a token for a analytics service.
Currently, it seems that next.js only properly supports specifying environment variables at build time, this leads to the following issue when using Docker.
- Build the docker image on CI with a specific (environment) configuration.
- Push the docker image to a repository.
- Pull/start the docker image on testing/staging/acceptance/production.
- Changing environment variables have no effect.
Describe the solution you'd like
I think there are type of environment variable that need to able to override:
- Frontend specific configuration (tokens for services like analytics).
- Backend/forntend configuration required for server side rendering the work correctly (api base url).
Being able to override the environment variables runtime would solve the first problem, but additional work on the server side render is probably also needed to support these cases properly.
Describe alternatives you've considered
An alternative would be to build specific Docker images for specific environments, however. I think this is considered an anti-pattern and should preferably be avoided.