go-gitea / gitea

Git with a cup of tea! Painless self-hosted all-in-one software development service, including Git hosting, code review, team collaboration, package registry and CI/CD
https://gitea.com
MIT License
45.23k stars 5.5k forks source link

when pushing multiple architecture and os of the same container package, the registry override image with the latest. #32170

Open ArKam opened 1 month ago

ArKam commented 1 month ago

Description

Hi team,

I was pushing a container to the container registry as a feature test, when I found out that the registry doesn't support storing a container image for different architecture using the same image name.

If you build an image for both, linux/arm64 and linux/x86_64 or windows/arm64 and windows/x86_64 and try to push each resulting image to the container registry, the latest build will override the previous package.

With docker hub or quay or ghcr, you can have the same URL: forge.domain.tld/owner/package:version that deliver container version depending on the client spec (arm/x86_64) in here, from my understanding and test so far, I'll have to create an image with a name that specify -arm64 or -x86_64.

Gitea Version

1.22.2

Can you reproduce the bug on the Gitea demo site?

Yes

Log Gist

No response

Screenshots

No response

Git Version

provided by gitea/gitea:1.22.2

Operating System

linux

How are you running Gitea?

Using kubernetes to deploy gitea/gitea:1.22.2 release.

Database

PostgreSQL

lunny commented 1 month ago

Can you describe your commands to upload the images or workflow file?

ArKam commented 1 month ago

Sure, I'm just using docker client to:

Docker build and push the image: docker build --push --platform linux/arm64 -t <forge_url>/<organisation>/<image_name>:<image_tag> . & docker build --push --platform linux/amd64 -t <forge_url>/<organisation>/<image_name>:<image_tag> .

Although I didn't tried the all in one command such as: docker build --push --platform linux/arm64,linux/amd64 -t <forge_url>/<organisation>/<image_name>:<image_tag> . As I use architecture dedicated runners.

hiifong commented 1 day ago

I guess you forgot to create a multi-arch manifest. img_v3_02gr_2c08eb2a-4d6e-48dc-bc93-3ddb277d104g

docker manifest create \
    {gitea.domain}/{owner}/{image}:latest \
    {gitea.domain}/{owner}/{image}:amd64 \
    {gitea.domain}/{owner}/{image}:arm64

docker manifest push {gitea.domain}/{owner}/{image}:latest
hiifong commented 1 day ago

Multi-architecture best practices: https://docs.docker.com/build/building/multi-platform/

hiifong commented 13 hours ago

I guess you forgot to create a multi-arch manifest. img_v3_02gr_2c08eb2a-4d6e-48dc-bc93-3ddb277d104g

docker manifest create \
    {gitea.domain}/{owner}/{image}:latest \
    {gitea.domain}/{owner}/{image}:amd64 \
    {gitea.domain}/{owner}/{image}:arm64

docker manifest push {gitea.domain}/{owner}/{image}:latest

image

However, this method will add some tags,it doesn't really solve your problem.Therefore, I recommend that you use docker buildx to create multi-architecture images.

docker buildx create --use --name {image}
docker buildx build --platform linux/amd64,linux/arm64 -t {gitea.domain}/{owner}/{image}:latest . --push