docker multiplatform build
All checks were successful
docker / build-docker (push) Successful in 3m1s

This commit is contained in:
royalcat 2024-12-23 17:21:58 +03:00
parent 33ec43b274
commit 15745bac2e

View file

@ -1,24 +1,32 @@
FROM golang:1.23 AS build
FROM --platform=${BUILDPLATFORM} golang:1.23 AS builder
ARG TARGETPLATFORM
ARG BUILDPLATFORM
ARG TARGETOS
ARG TARGETARCH
RUN go build -v std
WORKDIR /app
COPY go.mod ./
COPY go.sum ./
RUN go mod download
RUN --mount=type=cache,mode=0777,target=/go/pkg/mod go mod download all
COPY ./cmd ./cmd
COPY ./pkg ./pkg
COPY ./src ./src
RUN go build -tags timetzdata -o /server ./cmd/main.go
RUN --mount=type=cache,mode=0777,target=/go/pkg/mod \
CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH \
go build -tags timetzdata -o /server ./cmd/main.go
# run container
FROM scratch
#Adding root serts for ssl
COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY --from=build /server /app/konfa-server
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY --from=builder /server /app/konfa-server
WORKDIR /app