From 6f8ccd36e85fb457048a2e267723437a1e39230a Mon Sep 17 00:00:00 2001 From: Steffen Hildebrandt Date: Fri, 24 May 2024 09:12:25 +0200 Subject: [PATCH] build linux docker image with amd64 and arm64 --- .github/workflows/release.yaml | 29 +++++++++++++++++++++++------ Dockerfile | 4 +++- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index d03d9de..bd9da59 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -15,6 +15,10 @@ jobs: uses: actions/setup-go@v5 with: go-version: 1.22.1 + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 - name: Login to GitHub Container Registry uses: docker/login-action@v3 with: @@ -26,13 +30,26 @@ jobs: go install github.com/swaggo/swag/cmd/swag@latest swag init env GOOS=darwin GOARCH=arm64 go build -ldflags "-w -s" -o logicng-service-macos-arm main.go - env GOOS=darwin GOARCH=amd64 go build -ldflags "-w -s" -o logicng-service-macos-amd main.go - env GOOS=linux GOARCH=amd64 go build -ldflags "-w -s" -o logicng-service-linux main.go + env GOOS=darwin GOARCH=amd64 go build -ldflags "-w -s" -o logicng-service-macos-intel main.go + env GOOS=linux GOARCH=amd64 go build -ldflags "-w -s" -o logicng-service-linux-amd64 main.go + env GOOS=linux GOARCH=arm64 go build -ldflags "-w -s" -o logicng-service-linux-arm64 main.go env GOOS=windows GOARCH=amd64 go build -ldflags "-w -s" -o logicng-service-win.exe main.go - - name: Build and Push Docker Image - run: | - docker build . -t ghcr.io/booleworks/logicng-service:$(echo ${{ github.ref }} | cut -c 12-) - docker push ghcr.io/booleworks/logicng-service:$(echo ${{ github.ref }} | cut -c 12-) + - name: Build and Push AMD64 Image + uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: ghcr.io/booleworks/logicng-service:$(echo ${{ github.ref }} | cut -c 12-) + platforms: linux/amd64 + buildargs: PLATFORM=linux-amd64 + - name: Build and Push ARM64 Image + uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: ghcr.io/booleworks/logicng-service:$(echo ${{ github.ref }} | cut -c 12-) + platforms: linux/arm64 + buildargs: PLATFORM=linux-arm64 - name: Create GitHub Release uses: softprops/action-gh-release@v2 with: diff --git a/Dockerfile b/Dockerfile index 54afe62..0dd6d40 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,10 @@ +ARG PLATFORM FROM alpine:latest +LABEL org.opencontainers.image.source=https://github.com/booleworks/logicng-service ENV TIMEOUT 5s -COPY logicng-service-linux /opt/logicng-service +COPY logicng-service-$PLATFORM /opt/logicng-service EXPOSE 8080 CMD /opt/logicng-service --timeout $TIMEOUT