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(gh-actions): fix tagging docker image #2646

Merged

Conversation

moreal
Copy link
Contributor

@moreal moreal commented Nov 28, 2024

Context

Previously, the push_docker_image workflow tagged image incorrectly, tag for only one platform (not both linux/amd64 and linux/arm64). It was because of misunderstanding for docker pull and docker tag command.

Solution

So I researched the way and I found docker buildx imagetools create command. It can create a new manifest list from manifest list with a tag. (docker manifest cannot handle manifest list 😢)

The following lines are my shell output when testing locally. Because their digests are same with the original manifest, I believe that its behavior is just retagging.

% docker buildx imagetools create --progress=plain --tag=moreal/9c-headless:333 planetariumhq/ninechronicles-headless:git-08308b1134eaaa7a593350ebe59f12021b33fae7
#1 [internal] pushing docker.io/moreal/9c-headless:333
#1 0.000 copying sha256:37972d8de505d56f856e702479e83e6e16d5141f5bc2fbaaf1cc78749555a1b3 from docker.io/planetariumhq/ninechronicles-headless:git-08308b1134eaaa7a593350ebe59f12021b33fae7 to docker.io/moreal/9c-headless:333
#1 6.780 pushing sha256:37972d8de505d56f856e702479e83e6e16d5141f5bc2fbaaf1cc78749555a1b3 to docker.io/moreal/9c-headless:333
#1 DONE 7.0s
% docker manifest inspect moreal/9c-headless:333
{
   "schemaVersion": 2,
   "mediaType": "application/vnd.oci.image.index.v1+json",
   "manifests": [
      {
         "mediaType": "application/vnd.oci.image.manifest.v1+json",
         "size": 2011,
         "digest": "sha256:7f4aafb09979d926bc3188e83aea43217987d9ab3bbe34378d9f7e53b2571e46",
         "platform": {
            "architecture": "arm64",
            "os": "linux"
         }
      },
      {
         "mediaType": "application/vnd.oci.image.manifest.v1+json",
         "size": 2011,
         "digest": "sha256:674547a00e0574a03ec91aae913a5020f80081ee3bf170f15eab426bb01b257a",
         "platform": {
            "architecture": "amd64",
            "os": "linux"
         }
      },
      {
         "mediaType": "application/vnd.oci.image.manifest.v1+json",
         "size": 567,
         "digest": "sha256:fab32ecde32f5e80d6fe83d65c8e72b26008ebd2cbfad852f76b5c4df84a7f82",
         "platform": {
            "architecture": "unknown",
            "os": "unknown"
         }
      },
      {
         "mediaType": "application/vnd.oci.image.manifest.v1+json",
         "size": 567,
         "digest": "sha256:a13ca1fd21051c3eb221d998cb795849f7a71063e42e7974d9ab33f33338a805",
         "platform": {
            "architecture": "unknown",
            "os": "unknown"
         }
      }
   ]
}
% docker manifest inspect planetariumhq/ninechronicles-headless:git-08308b1134eaaa7a593350ebe59f12021b33fae7        
{
   "schemaVersion": 2,
   "mediaType": "application/vnd.oci.image.index.v1+json",
   "manifests": [
      {
         "mediaType": "application/vnd.oci.image.manifest.v1+json",
         "size": 2011,
         "digest": "sha256:7f4aafb09979d926bc3188e83aea43217987d9ab3bbe34378d9f7e53b2571e46",
         "platform": {
            "architecture": "arm64",
            "os": "linux"
         }
      },
      {
         "mediaType": "application/vnd.oci.image.manifest.v1+json",
         "size": 2011,
         "digest": "sha256:674547a00e0574a03ec91aae913a5020f80081ee3bf170f15eab426bb01b257a",
         "platform": {
            "architecture": "amd64",
            "os": "linux"
         }
      },
      {
         "mediaType": "application/vnd.oci.image.manifest.v1+json",
         "size": 567,
         "digest": "sha256:fab32ecde32f5e80d6fe83d65c8e72b26008ebd2cbfad852f76b5c4df84a7f82",
         "platform": {
            "architecture": "unknown",
            "os": "unknown"
         }
      },
      {
         "mediaType": "application/vnd.oci.image.manifest.v1+json",
         "size": 567,
         "digest": "sha256:a13ca1fd21051c3eb221d998cb795849f7a71063e42e7974d9ab33f33338a805",
         "platform": {
            "architecture": "unknown",
            "os": "unknown"
         }
      }
   ]
}

You can see the moreal/9c-headless:333 in Docker Hub

https://hub.docker.com/layers/moreal/9c-headless/333/images/sha256-7f4aafb09979d926bc3188e83aea43217987d9ab3bbe34378d9f7e53b2571e46?context=repo

References

@auto-assign auto-assign bot requested review from area363 and ipdae November 28, 2024 08:07
Copy link
Contributor

@sky1045 sky1045 left a comment

Choose a reason for hiding this comment

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

👍

@moreal moreal force-pushed the ci/gh-actions/fix-tagging-docker-image branch from 4c12001 to 069868f Compare November 28, 2024 09:25
@moreal moreal merged commit 2cfe859 into planetarium:development Nov 28, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants