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

ci: check image exists with Docker Hub API #1151

Merged

Conversation

MikeMcC399
Copy link
Collaborator

@MikeMcC399 MikeMcC399 commented Jul 7, 2024

Issue

When used in the CircleCI workflow workflow, the npm module docker-image-not-found outputs an error message "unsupported schema version 2" when attempting to check the existence of a Docker image on Docker Hub, if the image has been published with an oci type manifest instead of a docker type manifest.

Change

In the CircleCI workflow workflow, replace the npm module docker-image-not-found using a Docker HUB API call.

For example, the following command returns 0 if Docker Hub reports that the image is not found (HTTP 404), otherwise it returns 1. This works for docker and oci type manifests:

curl -s https://hub.docker.com/v2/namespaces/cypress/repositories/factory/tags/4.5.6 | grep -iq 'httperror 404'

Apart from the different parameter passing, the Docker HUB API) call is a drop-in replacement for docker-image-not-found.

@cypress-app-bot
Copy link

@MikeMcC399 MikeMcC399 force-pushed the replace/image-not-found branch 2 times, most recently from e714725 to d8eba72 Compare July 7, 2024 13:09
@MikeMcC399
Copy link
Collaborator Author

The following test workflow log demonstrates that the changed workflow is able to recognize published images on Docker Hub corresponding to the following tags. The workflow correctly halts in this case to prevent an attempt to republish:

FACTORY_VERSION=4.0.2
BASE_IMAGE_TAG=20.14.0
BROWSERS_IMAGE_TAG=node-20.14.0-chrome-126.0.6478.114-1-ff-127.0.1-edge-126.0.2592.61-1
INCLUDED_IMAGE_TAG=cypress-13.13.0-node-20.14.0-chrome-126.0.6478.114-1-ff-127.0.1-edge-126.0.2592.61-1

Log

@MikeMcC399 MikeMcC399 marked this pull request as ready for review July 7, 2024 13:22
circle.yml Outdated Show resolved Hide resolved
Co-authored-by: Bill Glesias <[email protected]>
Copy link
Member

@jennifer-shehane jennifer-shehane left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this. I think I can archive the docker-image-not-found repo with this update.

@jennifer-shehane jennifer-shehane merged commit 6a0ce0a into cypress-io:master Jul 8, 2024
31 checks passed
@jennifer-shehane
Copy link
Member

Archived that repo as I didn't see it used elsewhere

@MikeMcC399 MikeMcC399 deleted the replace/image-not-found branch July 8, 2024 15:21
@MikeMcC399
Copy link
Collaborator Author

@jennifer-shehane

I like this. I think I can archive the docker-image-not-found repo with this update.

That is a good move! The repo was a long way behind and even updating all dependencies would not solve the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants