Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Propagate environment #1358 #1392

Merged
merged 27 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
1a44ab3
adds propagate-environment tp pipeline #1358
ajain58 Jan 10, 2024
6fbc631
updates documentation
ajain58 Jan 17, 2024
17077f7
Merge branch 'seek-oss:master' into propagate-environment
ajain58 Jan 17, 2024
1857ca3
Adds back the missing github api token #1358
ajain58 Jan 18, 2024
e779bd7
Update documentation #1358
ajain58 Jan 18, 2024
66222f1
adds missing variables #1358
ajain58 Jan 19, 2024
35044ab
update documentation #1358
ajain58 Jan 19, 2024
0b56846
adds missing env variables #1358
ajain58 Jan 19, 2024
cd5f838
fixes lint and adds changeset #1358
ajain58 Jan 19, 2024
681328d
Merge branch 'master' into propagate-environment
ajain58 Jan 19, 2024
c31aa4b
Merge branch 'master' into propagate-environment
72636c Jan 20, 2024
5dfce6d
Merge branch 'master' into propagate-environment
72636c Jan 20, 2024
413537b
Merge branch 'master' into propagate-environment
ajain58 Jan 22, 2024
de9266b
support alternate repo folder names
samchungy Jan 22, 2024
f4b0a55
Update changeset and documentation
samchungy Jan 23, 2024
61d8499
Update new-crabs-buy.md
samchungy Jan 23, 2024
bbdd178
prettier
samchungy Jan 23, 2024
b0f4f6b
add VERSION environment variable
samchungy Jan 23, 2024
82b0e99
continue to explicitly pass `ENVIRONMENT`
samchungy Jan 23, 2024
1451c3c
pipeline vars get propagated automatically
samchungy Jan 23, 2024
2a81a60
Update pipeline.yml
samchungy Jan 23, 2024
6894985
Update github.md
samchungy Jan 23, 2024
6c3eb22
praise capitalism
samchungy Jan 23, 2024
a224ee3
Update diff
samchungy Jan 23, 2024
51b7fa9
Add one more line to diff
samchungy Jan 23, 2024
50a8f30
Update new-crabs-buy.md
72636c Jan 23, 2024
10ddc21
Update github.md
72636c Jan 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 36 additions & 1 deletion docs/deep-dives/github.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,33 @@ steps:
```

With Docker Compose,
declare the environment variables and volume mounts in your [Compose file]:
declare volume mounts in your [Compose file].

You won't need to declare the environment variables in the compose file since `propagate-environment: true` will ensure the variables defined are propagated to the docker environment.

For example, with the [Docker Buildkite plugin], we will need to add the `propagate-environment: true`:
ajain58 marked this conversation as resolved.
Show resolved Hide resolved
```yaml
steps:
- commands:
- pnpm run lint
- pnpm run test
env:
# At SEEK, this instructs the build agent to populate the GITHUB_API_TOKEN environment variable for this step.
GET_GITHUB_TOKEN: 'please'
plugins:
- docker#v5.0.0:
# Enable GitHub integrations.
environment:
- GITHUB_API_TOKEN
propagate-environment: true
volumes:
# Mount cached dependencies.
- /workdir/node_modules
ajain58 marked this conversation as resolved.
Show resolved Hide resolved
```

And then your [Compose file] will not need to define the `environment` like you had to before to ensure the environment variables are available in Docker

Docker compose file before:
samchungy marked this conversation as resolved.
Show resolved Hide resolved
```yaml
services:
app:
Expand All @@ -61,6 +86,16 @@ services:
- /workdir/node_modules
```

Docker compose file after:
```yaml
services:
app:
volumes:
- ./:/workdir
# Mount cached dependencies.
- /workdir/node_modules
```

If you're running in GitHub Actions,
your workflow will automatically have access to the following environment variables to achieve the same effect:

Expand Down
3 changes: 3 additions & 0 deletions template/express-rest-api/.buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ steps:
- *docker-ecr-cache
- docker-compose#v4.16.0:
run: app
environment:
- GITHUB_API_TOKEN
propagate-environment: true
timeout_in_minutes: 10

- label: 📦 Build & Package
Expand Down
10 changes: 0 additions & 10 deletions template/express-rest-api/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,6 @@ version: '3.7'

services:
app:
environment:
# Enable Buildkite + GitHub integrations.
- BUILDKITE
- BUILDKITE_AGENT_ACCESS_TOKEN
- BUILDKITE_BRANCH
- BUILDKITE_BUILD_NUMBER
- BUILDKITE_JOB_ID
- BUILDKITE_PIPELINE_DEFAULT_BRANCH
- BUILDKITE_STEP_ID
- GITHUB_API_TOKEN
ajain58 marked this conversation as resolved.
Show resolved Hide resolved
image: ${BUILDKITE_PLUGIN_DOCKER_IMAGE:-''}
init: true
volumes:
Expand Down
3 changes: 3 additions & 0 deletions template/greeter/.buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,7 @@ steps:
- *docker-ecr-cache
- docker-compose#v4.16.0:
run: app
environment:
- GITHUB_API_TOKEN
propagate-environment: true
timeout_in_minutes: 10
10 changes: 0 additions & 10 deletions template/greeter/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,6 @@ version: '3.7'

services:
app:
environment:
# Enable Buildkite + GitHub integrations.
- BUILDKITE
- BUILDKITE_AGENT_ACCESS_TOKEN
- BUILDKITE_BRANCH
- BUILDKITE_BUILD_NUMBER
- BUILDKITE_JOB_ID
- BUILDKITE_PIPELINE_DEFAULT_BRANCH
- BUILDKITE_STEP_ID
- GITHUB_API_TOKEN
image: ${BUILDKITE_PLUGIN_DOCKER_IMAGE:-''}
init: true
volumes:
Expand Down
3 changes: 3 additions & 0 deletions template/koa-rest-api/.buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ steps:
- *docker-ecr-cache
- docker-compose#v4.16.0:
run: app
environment:
- GITHUB_API_TOKEN
propagate-environment: true
timeout_in_minutes: 10

- label: 📦 Build & Package
Expand Down
10 changes: 0 additions & 10 deletions template/koa-rest-api/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,6 @@ version: '3.7'

services:
app:
environment:
# Enable Buildkite + GitHub integrations.
- BUILDKITE
- BUILDKITE_AGENT_ACCESS_TOKEN
- BUILDKITE_BRANCH
- BUILDKITE_BUILD_NUMBER
- BUILDKITE_JOB_ID
- BUILDKITE_PIPELINE_DEFAULT_BRANCH
- BUILDKITE_STEP_ID
- GITHUB_API_TOKEN
image: ${BUILDKITE_PLUGIN_DOCKER_IMAGE:-''}
init: true
volumes:
Expand Down
4 changes: 4 additions & 0 deletions template/lambda-sqs-worker-cdk/.buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ configs:
- docker-compose#v4.16.0:
dependencies: false
run: app
propagate-environment: true
retry:
manual:
# Only use this if you need to roll back a deployment ASAP.
Expand All @@ -56,6 +57,9 @@ steps:
- *docker-ecr-cache
- docker-compose#v4.16.0:
run: app
environment:
- GITHUB_API_TOKEN
ajain58 marked this conversation as resolved.
Show resolved Hide resolved
propagate-environment: true
timeout_in_minutes: 10

- agents:
Expand Down
15 changes: 0 additions & 15 deletions template/lambda-sqs-worker-cdk/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,6 @@ version: '3.7'

services:
app:
environment:
# Enable Buildkite + GitHub integrations.
- BUILDKITE
- BUILDKITE_AGENT_ACCESS_TOKEN
- BUILDKITE_BRANCH
- BUILDKITE_BUILD_NUMBER
- BUILDKITE_JOB_ID
- BUILDKITE_PIPELINE_DEFAULT_BRANCH
- BUILDKITE_STEP_ID
- GITHUB_API_TOKEN
# Tag AWS resources with the commit hash.
- BUILDKITE_COMMIT
# Pass through application configuration.
- ENVIRONMENT
- VERSION
image: ${BUILDKITE_PLUGIN_DOCKER_IMAGE:-''}
init: true
volumes:
Expand Down
4 changes: 4 additions & 0 deletions template/lambda-sqs-worker/.buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ configs:
- docker-compose#v4.16.0:
dependencies: false
run: app
propagate-environment: true
retry:
manual:
# Only use this if you need to roll back a deployment ASAP.
Expand Down Expand Up @@ -65,6 +66,9 @@ steps:
- *docker-ecr-cache
- docker-compose#v4.16.0:
run: app
environment:
- GITHUB_API_TOKEN
ajain58 marked this conversation as resolved.
Show resolved Hide resolved
propagate-environment: true
timeout_in_minutes: 10

- agents:
Expand Down
15 changes: 0 additions & 15 deletions template/lambda-sqs-worker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,6 @@ version: '3.7'

services:
app:
environment:
# Enable Buildkite + GitHub integrations.
- BUILDKITE
- BUILDKITE_AGENT_ACCESS_TOKEN
- BUILDKITE_BRANCH
- BUILDKITE_BUILD_NUMBER
- BUILDKITE_JOB_ID
- BUILDKITE_PIPELINE_DEFAULT_BRANCH
- BUILDKITE_STEP_ID
- GITHUB_API_TOKEN
# Tag AWS resources with the commit hash.
- BUILDKITE_COMMIT
# Pass through application configuration.
- ENVIRONMENT
- VERSION
ajain58 marked this conversation as resolved.
Show resolved Hide resolved
image: ${BUILDKITE_PLUGIN_DOCKER_IMAGE:-''}
init: true
volumes:
Expand Down
Loading