From 890c57dd74af6793394ab34d38a7e23db28056c5 Mon Sep 17 00:00:00 2001 From: Robin Olsen Date: Thu, 19 Feb 2026 22:31:05 +0100 Subject: [PATCH] make dockerfile multiplatofrm --- Dockerfile | 17 ++++++++++++++--- Makefile | 11 +++++++++-- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index e30de03..cf7e6e6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,21 @@ -FROM golang:1.25.6-alpine AS builder +FROM --platform=$BUILDPLATFORM golang:1.25.6-alpine AS builder WORKDIR /app + +RUN apk add --no-cache git ca-certificates tzdata + COPY go.mod go.sum ./ RUN go mod download + COPY . . -RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo \ - -ldflags="-w -s" -trimpath -o pm ./cmd/survey/ + +ARG TARGETOS +ARG TARGETARCH + +RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build \ + -a -installsuffix cgo \ + -ldflags="-w -s" \ + -trimpath \ + -o pm ./cmd/survey/ FROM gcr.io/distroless/static-debian13 WORKDIR /data diff --git a/Makefile b/Makefile index 64b1af4..22a0c28 100644 --- a/Makefile +++ b/Makefile @@ -17,8 +17,15 @@ build: tidy go build -o ./bin/web ./cmd/web go build -o ./bin/survey ./cmd/survey -docker-build: - @docker build -t telikz/lazypm . +enable-multiplatform-build: + @docker buildx create --name multiplatform --use 2>/dev/null || docker buildx use multiplatform + +docker-build: enable-multiplatform-build + @docker buildx build \ + --platform linux/amd64,linux/arm64,linux/arm/v7 \ + -t telikz/lazypm:latest \ + --push . + docker-run: @docker run -it -p 8080:8080 -v "$PWD:/data" telikz/lazypm:latest start