Skip to content

Commit a5f77e8

Browse files
authored
Adding custom environment variables details (#2869)
## Type of change **Documentation enhancement** This PR adds documentation for custom environment variables in Custom Assembly, expanding the existing custom annotations section to cover both features comprehensively. ### What should this PR do? resolves chainguard-dev/internal#5257 ### Why are we making this change? Custom Assembly supports adding custom environment variables to Chainguard Containers, but this capability was not documented. Users need to understand how to set runtime defaults and configuration values for their customized container images. ### What are the acceptance criteria? - [ ] Documentation clearly explains how to add custom environment variables using chainctl - [ ] Includes a practical example with common use cases (NODE_ENV, API_URL, PORT, LOG_LEVEL, CACHE_TTL) - [ ] Documents the restriction on CHAINGUARD_ prefixed environment variables - [ ] Section is logically organized alongside custom annotations documentation - [ ] Code examples use proper YAML formatting ### How should this PR be tested? 1. Review the documentation for clarity and completeness 2. Verify that the YAML examples are properly formatted 3. Confirm that the environment variable restrictions are clearly stated 4. Check that the new section flows naturally with the existing custom annotations section 5. Optionally: Test the documented commands against a Custom Assembly container to verify accuracy --------- Signed-off-by: Mark Drake <mark@chainguard.dev>
1 parent f911343 commit a5f77e8

File tree

1 file changed

+37
-2
lines changed

1 file changed

+37
-2
lines changed

content/chainguard/chainguard-images/features/ca-docs/custom-assembly-chainctl.md

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,11 @@ cgr.dev/example.com/custom-node
134134
Note that you **must** pass the new image's name when using the `--save-as` option; `chainctl` will return an error if you don't include a new name. Additionally, you can only use this option with the `edit` subcommand; you cannot create a new image declaratively using the `apply` subcommand.
135135

136136

137-
## Adding Custom Annotations
137+
## Adding Custom Annotations and Environment Variables
138+
139+
Custom Assembly lets you extend Chainguard Containers with your own metadata and runtime defaults by adding custom annotations and environment variables through `chainctl`.
140+
141+
### Custom annotations
138142

139143
Chainguard Containers include metadata in the form of *annotations*. These annotations provide important information about the container image's origin, contents, and characteristics.
140144

@@ -146,7 +150,7 @@ chainctl image repo build edit --parent $ORGANIZATION --repo $CONTAINER
146150

147151
In the text editor, add an `annotations` section to the bottom of the file like the following example:
148152

149-
```
153+
```yaml
150154
contents:
151155
packages:
152156
- jq
@@ -164,6 +168,37 @@ You can also apply custom annotations declaratively using the `apply` subcommand
164168

165169
Note that Custom Assembly blocks `org.opencontainers` and `dev.chainguard` annotations from being changed.
166170

171+
### Custom environment variables
172+
173+
Chainguard Containers often come with a set of predefined environment variables. These are useful for setting certain configuration details that are available to the container at runtime.
174+
175+
You can follow the same procedure for adding custom annotations to add custom environment variables to your Custom Assembly container images. Start by running a `chainctl image repo build edit` command:
176+
177+
```shell
178+
chainctl image repo build edit --parent $ORGANIZATION --repo $CONTAINER
179+
```
180+
181+
In the text editor, add an `environment` section like the following example:
182+
183+
```yaml
184+
contents:
185+
packages:
186+
- jq
187+
- git
188+
- curl
189+
190+
environment:
191+
NODE_ENV: production
192+
API_URL: https://api.example.com
193+
PORT: "3000"
194+
LOG_LEVEL: info
195+
CACHE_TTL: "300"
196+
```
197+
198+
After saving and confirming these changes, Custom Assembly will add these five custom environment variables to the container image. As with packages and annotations, you can also apply custom environment variables declaratively using the `apply` subcommand, as outlined previously.
199+
200+
Be aware that Custom Assembly blocks any environment variable that begins with `CHAINGUARD_` from being added or changed. This is to prevent conflicts with configuration details managed by Chainguard.
201+
167202

168203
## Retrieving Information about Custom Assembly Containers
169204

0 commit comments

Comments
 (0)