fix: Attempt docker pull before docker build when image not found locally#748
Open
raman1236 wants to merge 1 commit into
Open
fix: Attempt docker pull before docker build when image not found locally#748raman1236 wants to merge 1 commit into
raman1236 wants to merge 1 commit into
Conversation
…ally When docker_image is set to a pre-built registry image (e.g. public.ecr.aws/sam/build-python3.12:latest) and the image is not present locally, package.py now attempts 'docker pull' first. Previously it would fall back directly to 'docker build' using docker_build_root as the build context, which fails immediately when no Dockerfile is present (common case for Lambda source dirs). The fix tries 'docker pull <image>' first, and only falls back to 'docker build' if the pull fails (e.g. for custom/local images). Fixes terraform-aws-modules#746
46fc9f3 to
a309939
Compare
|
This PR has been automatically marked as stale because it has been open 30 days |
|
Not stale, still an issue. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #746
When
build_in_docker = trueanddocker_imageis set to a pre-built public registry image (e.g.public.ecr.aws/sam/build-python3.12:latest), if the image is not present locally,package.pyfalls back directly todocker buildusingdocker_build_rootas the build context. Since Lambda source directories typically don't contain a Dockerfile, this fails with:Changes
docker_pull_command()helper function alongside existingdocker_image_id_command()anddocker_build_command()docker pullbefore falling back todocker builddocker pullfails (e.g. for custom/local images), it falls back to the originaldocker buildbehaviorImpact
docker pullsucceeds, image is available locallydocker pullfails, falls back todocker build(same as before)docker imagescheck)