Skip to content
This repository was archived by the owner on Aug 26, 2024. It is now read-only.

Commit 41a63ff

Browse files
committed
Updating github docker build action to build for multiple platform
1 parent e41cf42 commit 41a63ff

File tree

1 file changed

+32
-22
lines changed

1 file changed

+32
-22
lines changed

.github/workflows/docker-publish.yml

+32-22
Original file line numberDiff line numberDiff line change
@@ -7,32 +7,42 @@ on:
77
- v*
88
jobs:
99
push_to_registries:
10-
name: Push Docker image to Dockerhub and Github
10+
name: Push Docker image to Dockerhub
1111
runs-on: ubuntu-latest
12+
env:
13+
DOCKER_REGISTRY: docker.io
14+
DOCKER_IMAGE: castyapp/dashboard
15+
DOCKER_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
16+
DOCKER_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
17+
DOCKER_TARGET_PLATFORM: linux/amd64,linux/arm64,linux/arm/v7
1218
steps:
1319
- name: Check out the repo
1420
uses: actions/checkout@v2
15-
- uses: docker/setup-buildx-action@v1
16-
17-
- name: Login to DockerHub
18-
uses: docker/login-action@v1
21+
22+
- name: Set up Docker Buildx
23+
uses: crazy-max/ghaction-docker-buildx@v2
1924
with:
20-
username: ${{ secrets.DOCKERHUB_USERNAME }}
21-
password: ${{ secrets.DOCKERHUB_TOKEN }}
22-
logout: true
25+
version: latest
2326

24-
- name: Build and Push to Docker Hub
25-
uses: docker/build-push-action@v2
26-
with:
27-
context: .
28-
file: ./Dockerfile
29-
tags: castylab/dashboard:latest
30-
push: true
27+
- name: Prepare
28+
if: success()
29+
id: prepare
30+
run: |
31+
echo ::set-output name=docker_platform::${DOCKER_TARGET_PLATFORM}
32+
echo ::set-output name=docker_image::${DOCKER_REGISTRY}/${DOCKER_IMAGE}
33+
echo ::set-output name=release_version::${GITHUB_REF#refs/*/}
3134
32-
- name: Build alpine and Push to Docker Hub
33-
uses: docker/build-push-action@v2
34-
with:
35-
context: .
36-
file: ./Dockerfile
37-
tags: castylab/dashboard:alpine
38-
push: true
35+
- name: Login to DockerHub
36+
if: success()
37+
run: |
38+
echo "${DOCKER_TOKEN}" | docker login ${DOCKER_REGISTRY} --username "${DOCKER_USERNAME}" --password-stdin
39+
40+
- name: Run Buildx (push image)
41+
if: success()
42+
run: |
43+
docker buildx build \
44+
--platform ${{ steps.prepare.outputs.docker_platform }} \
45+
--tag ${{ steps.prepare.outputs.docker_image }}:latest \
46+
--tag ${{ steps.prepare.outputs.docker_image }}:${{ steps.prepare.outputs.release_version }} \
47+
--file ./Dockerfile \
48+
--output type=image,push=true .

0 commit comments

Comments
 (0)