Use Branch: cra-buildvars
https://create-react-app.dev/docs/adding-custom-environment-variables/
- Create
envvariables with prefixREACT_APP_ - Have a
.envfile but don't put it in version control - Use
process.env.<ENV_VAR_NAME>in the code - Or, Use
%ENV_VAR_NAME%in the HTML code - Run
npm run startornpm run buildand inspect the generated static files - Problems: Cannot follow
build once, and deploy manyapproach. Every environment needs a different build.
Use Branch: envars
- Have a templated config for constants outside the core code
- Have a
.envfile but don't put it in version control envsubstutility is bundled with alpine docker image- Provide environment variable values at the run time (
docker run --env MYVAR1=foo) - Local environments: Use
.env.localfiles along with anpmutility calledenvsubthat works almost similar toenvsubstabove.
Use Branch: deps
-
Generate a healthz.json using the following command during the build
npm ls --depth=0 --json | jq ".status=\"green\"|.buildDate=\"$BUILD_DATE\"|.gitHash=\"$GIT_HASH\"" > healthz.json -
Configure nginx route for the
/healthzpath