docs(compose): Inlude example for build secrets on the use-secrets doc (#20403)

* docs: Inlude example for build secrets

* Apply suggestions from code review

---------

Co-authored-by: Allie Sadler <102604716+aevesdocker@users.noreply.github.com>
This commit is contained in:
Cesar Fernando Bonilla 2024-07-15 03:14:10 -06:00 committed by GitHub
parent bfd8501fb3
commit e6847231e2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 18 additions and 0 deletions

View File

@ -84,7 +84,25 @@ In the advanced example above:
>
> The `_FILE` environment variables demonstrated here are a convention used by some images, including Docker Official Images like [mysql](https://hub.docker.com/_/mysql) and [postgres](https://hub.docker.com/_/postgres).
### Build secrets
In the following example, the `npm_token` secret is made available at build time. It's value is taken from the `NPM_TOKEN` environment variable.
```yaml
services:
myapp:
build:
secrets:
- npm_token
context: .
secrets:
npm_token:
environment: NPM_TOKEN
```
## Resources
- [Secrets top-level element](compose-file/09-secrets.md)
- [Secrets attribute for services top-level element](compose-file/05-services.md#secrets)
- [Build secrets](https://docs.docker.com/build/building/secrets/)