make dockerfile multiplatofrm
This commit is contained in:
17
Dockerfile
17
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
|
WORKDIR /app
|
||||||
|
|
||||||
|
RUN apk add --no-cache git ca-certificates tzdata
|
||||||
|
|
||||||
COPY go.mod go.sum ./
|
COPY go.mod go.sum ./
|
||||||
RUN go mod download
|
RUN go mod download
|
||||||
|
|
||||||
COPY . .
|
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
|
FROM gcr.io/distroless/static-debian13
|
||||||
WORKDIR /data
|
WORKDIR /data
|
||||||
|
|||||||
11
Makefile
11
Makefile
@@ -17,8 +17,15 @@ build: tidy
|
|||||||
go build -o ./bin/web ./cmd/web
|
go build -o ./bin/web ./cmd/web
|
||||||
go build -o ./bin/survey ./cmd/survey
|
go build -o ./bin/survey ./cmd/survey
|
||||||
|
|
||||||
docker-build:
|
enable-multiplatform-build:
|
||||||
@docker build -t telikz/lazypm .
|
@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:
|
||||||
@docker run -it -p 8080:8080 -v "$PWD:/data" telikz/lazypm:latest start
|
@docker run -it -p 8080:8080 -v "$PWD:/data" telikz/lazypm:latest start
|
||||||
|
|||||||
Reference in New Issue
Block a user