From f6206a97bf2453ed53a81ca88dab0c2bc6b4ac95 Mon Sep 17 00:00:00 2001 From: karlderkaefer Date: Tue, 30 Apr 2024 12:12:14 +0200 Subject: [PATCH] fix: arm64 docker image closes #160 --- Dockerfile | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 41dc80a..c7a218d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -26,9 +26,11 @@ RUN --mount=type=cache,target=/go/pkg/mod/ \ # Leverage a cache mount to /go/pkg/mod/ to speed up subsequent builds. # Leverage a bind mount to the current directory to avoid having to copy the # source code into the container. +ARG TARGETOS +ARG TARGETARCH RUN --mount=type=cache,target=/go/pkg/mod/ \ --mount=type=bind,target=. \ - CGO_ENABLED=0 go build -o /bin/cdk-notifier . + CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH go build -o /bin/cdk-notifier . ################################################################################ # Create a new stage for running the application that contains the minimal @@ -41,12 +43,11 @@ RUN --mount=type=cache,target=/go/pkg/mod/ \ # most recent version of that image when you build your Dockerfile. If # reproducability is important, consider using a versioned tag # (e.g., alpine:3.17.2) or SHA (e.g., alpine:sha256:c41ab5c992deb4fe7e5da09f67a8804a46bd0592bfdf0b1847dde0e0889d2bff). -FROM --platform=$BUILDPLATFORM alpine:latest AS final +FROM --platform=$TARGETPLATFORM alpine:latest AS final # Install any runtime dependencies that are needed to run your application. # Leverage a cache mount to /var/cache/apk/ to speed up subsequent builds. -RUN --mount=type=cache,target=/var/cache/apk \ - apk --update add \ +RUN apk --update add \ ca-certificates \ tzdata \ && \