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

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

Open
1 of 2 tasks
pechersky opened this issue Feb 11, 2025 · 1 comment
Open
1 of 2 tasks
Labels
@aws-cdk/core Related to core CDK functionality effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p2

Comments

@pechersky
Copy link

Describe the feature

We add a readonly alwaysPullReference?: boolean to the DockerBuildOptions interface, which is then used in the dockerArgs to 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 herehttps://github.com/aws/aws-cdk/blob/main/packages/aws-cdk-lib/core/lib/bundling.ts#L361:

..(options.alwaysPullReference ? ['--pull'] : []),

Other Information

No response

Acknowledgements

  • 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)

@pechersky pechersky added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Feb 11, 2025
@github-actions github-actions bot added the @aws-cdk/core Related to core CDK functionality label Feb 11, 2025
@pahud
Copy link
Contributor

pahud commented Feb 11, 2025

Thanks for the feature request! This is a great suggestion that would provide more granular control over docker image pulling behavior during builds.

The proposed alwaysPullReference option makes sense because:

  1. It's more efficient than --no-cache when you only want to ensure referenced base images are up-to-date
  2. It follows existing docker CLI conventions with the --pull flag
  3. It's backward compatible as an optional parameter

The implementation looks straightforward and clean. While it looks fine with me, I'm bringing it up to CDK team for further inputs.

@pahud pahud added p2 effort/medium Medium work item – several days of effort and removed needs-triage This issue or PR still needs to be triaged. labels Feb 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/core Related to core CDK functionality effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p2
Projects
None yet
Development

No branches or pull requests

2 participants