aws / aws/aws-cdk

core: add `--pull` option to `DockerBuldOptions` to allow force pull of referenced images

Open
#33,400 1 comment 1 reaction 0 assignees View on GitHub
@aws-cdk/core effort/medium feature-request p2
Dominant language
TypeScript
Stars
12.9k
Forks
4.6k
Avg merge
1d 19h
Merged PRs (30d)
74

Description

### Describe the feature

We add a `readonly alwaysPullReference?: boolean` to the `DockerBuildOptions` interface, which is [then used in the `dockerArgs` to ](https://github.com/aws/aws-cdk/blob/main/packages/aws-cdk-lib/core/lib/bundling.ts#L356-L362)add a `--pull` argument to the `docker build` command. This will allow users to run the `docker build` command which always tries to use the most recent referenced images.

### Use Case

In the `docker build` step, we allow the user to turn caching off via `cacheDisabled`. When deploying a stack locally, I want to make sure that my referenced images in Dockerfiles in `FROM some/remote:tag` are up to date. The `docker build --pull` command does this by basically in-lining a `docker pull some/remote:tag; docker build`. This is more surgical than a `--no-cache` since `--no-cache` invalidates all layers. However, in the `build --pull` case, if the referenced image is up-to-date, all the existing layers are in sync; or if it is not, only the stages that rely on the now updated reference image will need new layers.

### Proposed Solution

Add a line here https://github.com/aws/aws-cdk/blob/main/packages/aws-cdk-lib/core/lib/bundling.ts#L361:
```
..(options.alwaysPullReference ? ['--pull'] : []),
```

### Other Information

_No response_

### Acknowledgements

- [x] I may be able to implement this feature request
- [ ] This feature might incur a breaking change

### CDK version used

2.178.1

### Environment details (OS name and version, etc.)

Ubuntu 20.04 (WSL)

Contributor guide

Open the contributing guide

Research direction

Start in packages/aws-cdk-lib/core/lib/bundling.ts at DockerBuildOptions and the dockerArgs construction around the referenced lines. Add the optional alwaysPullReference behavior so the Docker build command includes --pull when enabled, and confirm the existing bundling behavior remains unchanged when it is not.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, typescript
Domain
build-system
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.