Skip to content

UI App configuration for environment variables, health checks, and dependency list

Notifications You must be signed in to change notification settings

PraveenSalitra/12factor-ui-app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Using Environment Variables baked at Build Time

Use Branch: cra-buildvars
https://create-react-app.dev/docs/adding-custom-environment-variables/

  1. Create env variables with prefix REACT_APP_
  2. Have a .env file but don't put it in version control
  3. Use process.env.<ENV_VAR_NAME> in the code
  4. Or, Use %ENV_VAR_NAME% in the HTML code
  5. Run npm run start or npm run build and inspect the generated static files
  6. Problems: Cannot follow build once, and deploy many approach. Every environment needs a different build.

Using Environment Variables within nginx docker containers

Use Branch: envars

  1. Have a templated config for constants outside the core code
  2. Have a .env file but don't put it in version control
  3. envsubst utility is bundled with alpine docker image
  4. Provide environment variable values at the run time (docker run --env MYVAR1=foo)
  5. Local environments: Use .env.local files along with a npm utility called envsub that works almost similar to envsubst above.

Generate Dependency List and healthchecks for nginx docker containers

Use Branch: deps

  1. 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

  2. Configure nginx route for the /healthz path

About

UI App configuration for environment variables, health checks, and dependency list

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published