make dockerfile multiplatofrm

This commit is contained in:
Robin Olsen
2026-02-19 22:31:05 +01:00
parent aa8e0c1f06
commit 890c57dd74
2 changed files with 23 additions and 5 deletions

View File

@@ -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

View File

@@ -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