Skip to content

Commit accf4a9

Browse files
committed
Use "imagetools" to create manifests
1 parent c732796 commit accf4a9

File tree

1 file changed

+41
-23
lines changed

1 file changed

+41
-23
lines changed

.github/workflows/docker-build.yml

Lines changed: 41 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,16 @@ jobs:
7878
permissions:
7979
packages: write
8080
steps:
81+
- name: Set up QEMU
82+
uses: docker/setup-qemu-action@v3
83+
84+
- name: Setup Docker Buildx
85+
uses: docker/setup-buildx-action@v3
86+
with:
87+
driver-opts: |
88+
image=moby/buildkit:latest
89+
network=host
90+
8191
- name: Log in to GHCR
8292
uses: docker/login-action@v3
8393
with:
@@ -86,28 +96,36 @@ jobs:
8696
password: ${{ secrets.GITHUB_TOKEN }}
8797

8898
- name: Create and push CPU manifest
89-
uses: docker/build-push-action@v6
90-
with:
91-
context: .
92-
target: builder
93-
platforms: linux/amd64,linux/arm64
94-
push: true
95-
provenance: false
96-
tags: |
97-
ghcr.io/${{ github.repository }}:cpu
98-
${{ startsWith(github.ref, 'refs/tags/') && format('ghcr.io/{0}:cpu-{1}', github.repository, github.ref_name) || '' }}
99-
${{ github.ref == 'refs/heads/main' && format('ghcr.io/{0}:latest', github.repository) || '' }}
100-
outputs: type=image,name=ghcr.io/${{ github.repository }},annotation-index.org.opencontainers.image.title=Python Tutorial,annotation-index.org.opencontainers.image.description=A containerized Python tutorial environment with Jupyter Lab.
99+
run: |
100+
# Create and push multi-architecture manifest for CPU variant
101+
docker buildx imagetools create --tag ghcr.io/${{ github.repository }}:cpu \
102+
ghcr.io/${{ github.repository }}:cpu-amd64 \
103+
ghcr.io/${{ github.repository }}:cpu-arm64
104+
105+
# If on main branch, also tag as latest
106+
if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then
107+
docker buildx imagetools create --tag ghcr.io/${{ github.repository }}:latest \
108+
ghcr.io/${{ github.repository }}:cpu-amd64 \
109+
ghcr.io/${{ github.repository }}:cpu-arm64
110+
fi
111+
112+
# If this is a tag, add version tag for CPU
113+
if [[ "${{ startsWith(github.ref, 'refs/tags/') }}" == "true" ]]; then
114+
docker buildx imagetools create --tag ghcr.io/${{ github.repository }}:cpu-${{ github.ref_name }} \
115+
ghcr.io/${{ github.repository }}:cpu-amd64 \
116+
ghcr.io/${{ github.repository }}:cpu-arm64
117+
fi
101118
102119
- name: Create and push CUDA manifest
103-
uses: docker/build-push-action@v6
104-
with:
105-
context: .
106-
target: builder
107-
platforms: linux/amd64,linux/arm64
108-
push: true
109-
provenance: false
110-
tags: |
111-
ghcr.io/${{ github.repository }}:cuda
112-
${{ startsWith(github.ref, 'refs/tags/') && format('ghcr.io/{0}:cuda-{1}', github.repository, github.ref_name) || '' }}
113-
outputs: type=image,name=ghcr.io/${{ github.repository }},annotation-index.org.opencontainers.image.title=Python Tutorial,annotation-index.org.opencontainers.image.description=A containerized Python tutorial environment with Jupyter Lab.
120+
run: |
121+
# Create and push multi-architecture manifest for CUDA variant
122+
docker buildx imagetools create --tag ghcr.io/${{ github.repository }}:cuda \
123+
ghcr.io/${{ github.repository }}:cuda-amd64 \
124+
ghcr.io/${{ github.repository }}:cuda-arm64
125+
126+
# If this is a tag, add version tag for CUDA
127+
if [[ "${{ startsWith(github.ref, 'refs/tags/') }}" == "true" ]]; then
128+
docker buildx imagetools create --tag ghcr.io/${{ github.repository }}:cuda-${{ github.ref_name }} \
129+
ghcr.io/${{ github.repository }}:cuda-amd64 \
130+
ghcr.io/${{ github.repository }}:cuda-arm64
131+
fi

0 commit comments

Comments
 (0)