Skip to content

Commit 41495d1

Browse files
authored
Update docker-image.yml
Add a multi-platform docker image build
1 parent 91dfd64 commit 41495d1

File tree

1 file changed

+16
-23
lines changed

1 file changed

+16
-23
lines changed

.github/workflows/docker-image.yml

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ jobs:
2626
with:
2727
dotnet-version: ${{ env.DOTNET_VERSION }}
2828

29+
- name: Set up QEMU
30+
uses: docker/setup-qemu-action@v3
31+
32+
- name: Set up Docker Buildx
33+
uses: docker/setup-buildx-action@v3
34+
2935
- name: Log in to Docker Hub
3036
uses: docker/login-action@v3
3137
with:
@@ -42,26 +48,13 @@ jobs:
4248
fi
4349
echo "version=$VERSION" >> $GITHUB_OUTPUT
4450
45-
- name: Build Docker image
46-
run: |
47-
IMAGE=$DOCKER_USER/$APP_NAME
48-
VERSION=${{ steps.vars.outputs.version }}
49-
50-
echo "Building $IMAGE:$VERSION" from $DOCKERFILE_PATH
51-
docker build -t $IMAGE:$VERSION -f $DOCKERFILE_PATH .
52-
53-
# if this is a tag → push latest version as well
54-
if [ "$VERSION" != "latest" ]; then
55-
docker tag $IMAGE:$VERSION $IMAGE:latest
56-
fi
57-
58-
- name: Push Docker image
59-
run: |
60-
IMAGE=$DOCKER_USER/$APP_NAME
61-
VERSION=${{ steps.vars.outputs.version }}
62-
63-
docker push $IMAGE:$VERSION
64-
65-
if [ "$VERSION" != "latest" ]; then
66-
docker push $IMAGE:latest
67-
fi
51+
- name: Build and push Docker image
52+
uses: docker/build-push-action@v5
53+
with:
54+
context: .
55+
file: ${{ env.DOCKERFILE_PATH }}
56+
platforms: linux/amd64,linux/arm64,linux/arm/v7
57+
push: true
58+
tags: |
59+
${{ secrets.DOCKERHUB_USERNAME }}/${{ env.APP_NAME }}:${{ steps.vars.outputs.version }}
60+
${{ secrets.DOCKERHUB_USERNAME }}/${{ env.APP_NAME }}:latest

0 commit comments

Comments
 (0)