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

Zach/wit-1564-during-build-step-of-existing-image-service-check-image #173

Open
wants to merge 1 commit into
base: zach/wit-1551-validate-service-type-is-known-for-flavor-when-saving
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion src/cnc/flavors/aws/ecs/1/build/build_functions.sh.j2
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,25 @@ push_{{ service.name }}_image_tags () {
verify_{{ service.name }}_image_exists () {
echo -e "\\nSkipping image build - using existing image."
echo -e "\\nVerifying image exists...\\n"
docker manifest inspect {{ service.image_for_tag(builder.tag_for_service(service.name)) }}

IMAGE="{{ service.image_for_tag(builder.tag_for_service(service.name)) }}"

# Enable Docker experimental features
export DOCKER_CLI_EXPERIMENTAL=enabled

# Check if the image exists and get its manifest
if ! MANIFEST=$(docker manifest inspect $IMAGE 2>/dev/null); then
echo "Error: Image $IMAGE does not exist or cannot be accessed."
exit 1
fi

# Check if the image supports AMD64 architecture
if ! echo "$MANIFEST" | jq -e '.manifests[] | select(.platform.architecture == "amd64")' > /dev/null; then
echo "Error: Image $IMAGE does not support AMD64 architecture."
exit 1
fi

echo "Image $IMAGE exists and supports AMD64 architecture."
}
{% endif %}

Expand Down
24 changes: 24 additions & 0 deletions src/cnc/flavors/gcp/shared/build/build_functions.sh.j2
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,30 @@ verify_{{ service.name }}_image_exists () {
echo -e "\\nSkipping image build - using existing image."
echo -e "\\nVerifying image exists...\\n"
docker manifest inspect {{ service.image_for_tag(builder.tag_for_service(service.name)) }}

verify_{{ service.name }}_image_exists () {
echo -e "\\nSkipping image build - using existing image."
echo -e "\\nVerifying image exists...\\n"

IMAGE="{{ service.image_for_tag(builder.tag_for_service(service.name)) }}"

# Enable Docker experimental features
export DOCKER_CLI_EXPERIMENTAL=enabled

# Check if the image exists and get its manifest
if ! MANIFEST=$(docker manifest inspect $IMAGE 2>/dev/null); then
echo "Error: Image $IMAGE does not exist or cannot be accessed."
exit 1
fi

# Check if the image supports AMD64 architecture
if ! echo "$MANIFEST" | jq -e '.manifests[] | select(.platform.architecture == "amd64")' > /dev/null; then
echo "Error: Image $IMAGE does not support AMD64 architecture."
exit 1
fi

echo "Image $IMAGE exists and supports AMD64 architecture."
}
}

{% if not service.image %}
Expand Down