From dda5144062152e43d33f6424fb25ed3a16dbe04e Mon Sep 17 00:00:00 2001 From: Kaan Yagci <9104546+kaanyagci@users.noreply.github.com> Date: Fri, 29 Mar 2024 18:42:35 +0100 Subject: [PATCH] fix: multi-plaform builds (#4) * chore: add Dockerfile Signed-off-by: Kaan Yagci * fixup! chore: add Dockerfile fix: syntax issue Signed-off-by: Kaan Yagci * fixup! chore: add Dockerfile fix: image name syntax error Signed-off-by: Kaan Yagci * fixup! chore: add Dockerfile fix: add missing update to install wget Signed-off-by: Kaan Yagci * fix: multiplatform docker build Signed-off-by: Kaan Yagci * chore: apply different builds on Go download Signed-off-by: Kaan Yagci * fix(gha): go version added to the image Signed-off-by: Kaan Yagci * fix(gha): go version added to the image Signed-off-by: Kaan Yagci * chore: update Dockerfile" Signed-off-by: Kaan Yagci * chore: test Dockerfile Signed-off-by: Kaan Yagci * chore: testing dockerile arguments Signed-off-by: Kaan Yagci * chore: debugging Dockerfile build arguments Signed-off-by: Kaan Yagci * chore: remove --platform from FROM Signed-off-by: Kaan Yagci * chore: debugging Dockefile Signed-off-by: Kaan Yagci * chore: simplify Signed-off-by: Kaan Yagci * fix: Dockerfile Signed-off-by: Kaan Yagci --------- Signed-off-by: Kaan Yagci Signed-off-by: Kaan Yagci <9104546+kaanyagci@users.noreply.github.com> --- .../workflows/build_and_push_docker_image.yml | 23 +++++-------------- Dockerfile | 12 ++++++---- 2 files changed, 14 insertions(+), 21 deletions(-) diff --git a/.github/workflows/build_and_push_docker_image.yml b/.github/workflows/build_and_push_docker_image.yml index cdfca98..385cd2f 100644 --- a/.github/workflows/build_and_push_docker_image.yml +++ b/.github/workflows/build_and_push_docker_image.yml @@ -46,29 +46,18 @@ jobs: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_PASSWORD }} - - name: Build Docker image - uses: docker/build-push-action@v5.3.0 - with: - context: . - file: Dockerfile - load: true # Change to load for PRs, no push - tags: makepad/go-opencv:${{ matrix.DEBIAN_TAG }}-${{ matrix.OPENCV_VERSION }} - build-args: | - DEBIAN_TAG=${{ matrix.DEBIAN_TAG }} - OPENCV_VERSION=${{ matrix.OPENCV_VERSION }} - GO_VERSION=${{matrix.GO_VERSION}} - - - name: Push Docker image - if: github.event_name == 'push' + + - name: Build and Push Docker image uses: docker/build-push-action@v5.3.0 with: context: . file: Dockerfile - push: true + platforms: linux/amd64,linux/arm64/v8 + push: ${{ github.event_name == 'push' }} tags: makepad/go-opencv:${{ matrix.DEBIAN_TAG }}-opencv-${{ matrix.OPENCV_VERSION }}-go${{ matrix.GO_VERSION }} build-args: | DEBIAN_TAG=${{ matrix.DEBIAN_TAG }} OPENCV_VERSION=${{ matrix.OPENCV_VERSION }} - GO_VERSION=${{matrix.GO_VERSION}} - cache-from: type=registry,ref=makepad/opencv:${{ matrix.DEBIAN_TAG }}-opencv-${{ matrix.OPENCV_VERSION }}-go-${{ matrix.GO_VERSION }} + GO_VERSION=${{ matrix.GO_VERSION }} + cache-from: type=registry,ref=makepad/go-opencv:${{ matrix.DEBIAN_TAG }}-opencv-${{ matrix.OPENCV_VERSION }}-go${{ matrix.GO_VERSION }} cache-to: type=inline diff --git a/Dockerfile b/Dockerfile index 67fb51d..b3c9ea8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,17 +1,21 @@ ARG OPENCV_VERSION ARG DEBIAN_TAG +ARG GO_VERSION FROM makepad/opencv:${DEBIAN_TAG}-${OPENCV_VERSION} +ARG TARGETOS +ARG TARGETARCH ARG GO_VERSION WORKDIR /app + RUN apt-get update -y && \ - apt-get install -y wget tar --no-install-recommends && \ - wget -q "https://go.dev/dl/go${GO_VERSION}.linux-amd64.tar.gz" && \ - tar -C /usr/local -xzf go${GO_VERSION}.linux-amd64.tar.gz && \ - rm ./go${GO_VERSION}.linux-amd64.tar.gz +apt-get install -y wget tar --no-install-recommends && \ + wget -q "https://go.dev/dl/go${GO_VERSION}.${TARGETOS}-${TARGETARCH}.tar.gz" && \ + tar -C /usr/local -xzf go${GO_VERSION}.${TARGETOS}-${TARGETARCH}.tar.gz && \ + rm ./go${GO_VERSION}.${TARGETOS}-${TARGETARCH}.tar.gz # Set Go environment variables ENV PATH="${PATH}:/usr/local/go/bin"