Use Branch: cra-buildvars
https://create-react-app.dev/docs/adding-custom-environment-variables/
- Create
env
variables with prefixREACT_APP_
- Have a
.env
file 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 start
ornpm run build
and inspect the generated static files - Problems: Cannot follow
build once, and deploy many
approach. Every environment needs a different build.
Use Branch: envars
- Have a templated config for constants outside the core code
- Have a
.env
file but don't put it in version control envsubst
utility is bundled with alpine docker image- Provide environment variable values at the run time (
docker run --env MYVAR1=foo
) - Local environments: Use
.env.local
files along with anpm
utility calledenvsub
that works almost similar toenvsubst
above.
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
/healthz
path