Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
flemay committed Jan 21, 2024
1 parent 7322386 commit e291cee
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 18 deletions.
26 changes: 11 additions & 15 deletions docs/guide/environment-variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,26 +52,21 @@ docker compose run --rm alpine env
Refer to section [Tutorial][linkSectionTutorial] for in-depth demonstration.
:::

## Structure envfile
## Naming and envfile structure

Environment variables can be used at different stages of software development: build, test, deploy, and run time. The following is an example how to keep envfile structured.
Environment variables for an application can be mixed with other environment variables coming from other applications/dependencies. One way to distinguish from one to another is to prepend with something like `ENV_`. This makes it easy when you want to only see them: `env | grep ENV_`. One example is GitHub Actions as it uses [environment variables starting with `GITHUB_`][linkGitHubActionsEnvVars].

```bash
# .env
# All
ENV

# Deploy
AWS_VPC
Also, environment variables can be used at different stages of software development: build, test, deploy, and run time. Naming them accordingly may be a good idea.

# Test
CODECOV_URL
Naming variables and structuring envfile is a personal taste. Currently I prefer structuring it by ordering variables and descriptions:

# Build and deploy
BUILD_DIR
```bash
# env.template

# Test and run
DB_HOST
# ENV_MY_VAR_1 is description 1
# ENV_MY_VAR_2 is description 2
ENV_MY_VAR_1
ENV_MY_VAR_2
```

## Template and example envfiles
Expand Down Expand Up @@ -497,3 +492,4 @@ Questions:
[link12factorConfig]: https://12factor.net/config
[linkDockerEnvfile]: https://docs.docker.com/compose/env-file/
[linkDockerComposeVarialeSubstitution]: https://docs.docker.com/compose/compose-file/#variable-substitution
[linkGitHubActionsEnvVars]: https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables
2 changes: 1 addition & 1 deletion env.example
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
NETLIFY_SITE_ID=ID
NETLIFY_AUTH_TOKEN=token
NETLIFY_SITE_ID=ID
4 changes: 2 additions & 2 deletions env.template
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# NETLIFY_SITE_ID is the API ID found in the Netlify site details
NETLIFY_SITE_ID
# NETLIFY_AUTH_TOKEN is the personal access token in the applications in Netlify user settings
# NETLIFY_SITE_ID is the API ID found in the Netlify site details
NETLIFY_AUTH_TOKEN
NETLIFY_SITE_ID

0 comments on commit e291cee

Please sign in to comment.