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

Replace docker-image-not-found in CircleCI publish workflow #1142

Closed
MikeMcC399 opened this issue Jul 3, 2024 · 1 comment · Fixed by #1151
Closed

Replace docker-image-not-found in CircleCI publish workflow #1142

MikeMcC399 opened this issue Jul 3, 2024 · 1 comment · Fixed by #1151
Assignees

Comments

@MikeMcC399
Copy link
Collaborator

MikeMcC399 commented Jul 3, 2024

What would you like?

The npm module docker-image-not-found, sourced from the repo cypress-io/docker-image-not-found, is out of date and should be replaced.

Why is this needed?

The npm module docker-image-not-found is on the critical path for releasing Cypress Docker images to the repositories Docker Hub and Amazon ECR (Elastic Container Registry) Public Gallery.

The module is used in the CircleCI workflow command halt-if-docker-image-exists.

docker-image-not-found (current latest), which was released in March 2020, is not compatible with default multi-architecture manifests using OCI formats. If an OCI type image exists, then docker-image-not-found reports the same 1 return code as for an existing docker manifest image. The error log however shows that there has been a problem evaluating the manifest, leading to loss of confidence in the module's reliability.

The following issues would need to be resolved in order to continue to use it in the medium term:

Considering that its only function is to check for the existence of an image, the effort to update it to current environments is out of proportion to its benefit. The original repo https://github.com/mishguruorg/docker-image-exists, from which it was forked, was last updated 7 years ago and would not be helpful for any update.

Other

Related

@MikeMcC399
Copy link
Collaborator Author

Recap

A solution for checking if an image has already been published to Docker Hub is needed which covers both the older docker type and the newer oci type. This issue is preventing further version updates taking place (see #1095 & #1145).

Solution suggestion

Using the Docker HUB API (beta)'s Check repository tag with the following format it is possible to replace the outdated npm module docker-image-not-found. The API does not require a Docker client and is therefore independent of any Docker engine version installed:

https://hub.docker.com/v2/namespaces/{namespace}/repositories/{repository}/tags/{tag}

For instance

curl -s https://hub.docker.com/v2/namespaces/cypress/repositories/factory/tags/4.0.2 | grep -iq 'httperror 404'
echo $?
curl -s https://hub.docker.com/v2/namespaces/cypress/repositories/factory/tags/missing | grep -iq 'httperror 404'
echo $?
  • returns 1 (failure) = image exists (not 'not found')
  • returns 0 (success) = image check returned HTTP 404 'not found'

respectively, exactly as docker-image-not-found does.

Additionally the API is able to cope with images that have an imageType oci. For example, we can check the method using ubuntu/jammy which has converted to vnd.oci.image:

$ curl -s https://hub.docker.com/v2/namespaces/library/repositories/ubuntu/tags/jammy | python -mjson.tool | grep media_
type
    "media_type": "application/vnd.oci.image.index.v1+json",

and executing this command against the oci image correctly returns the expected result:

curl -s https://hub.docker.com/v2/namespaces/library/repositories/ubuntu/tags/jammy | grep -iq 'httperror 404'
echo $?
  • returns 1 (failure) = image exists. This is despite it having an oci manifest.

Note that the experimental Docker command docker manifest inspect in the currently used Docker engine 20.10 fails to recognize images with an oci manifest, and so it is not yet a candidate to replace docker-image-not-found. It does however work in later versions such as Docker engine 24.0 and its status can be monitored to see if docker manifest inspect should be used at a later time.

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

Successfully merging a pull request may close this issue.

1 participant