-
-
Notifications
You must be signed in to change notification settings - Fork 80
Expand file tree
/
Copy pathprod.Dockerfile
More file actions
38 lines (25 loc) · 963 Bytes
/
prod.Dockerfile
File metadata and controls
38 lines (25 loc) · 963 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# Build environment
# -----------------
FROM --platform=$BUILDPLATFORM golang:1.26rc2-alpine as build-env
WORKDIR /myapp
ENV GOEXPERIMENT=jsonv2
RUN apk add --no-cache tzdata ca-certificates
COPY go.mod go.sum ./
RUN --mount=type=cache,target=/go/pkg/mod go mod download
COPY . .
ARG TARGETOS TARGETARCH
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg/mod \
CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH \
go build -ldflags '-w -s' -o ./bin/app ./cmd/app \
&& go build -ldflags '-w -s' -o ./bin/migrate ./cmd/migrate
# Deployment environment
# ----------------------
FROM gcr.io/distroless/static-debian12
ENV TZ=Asia/Singapore
COPY --from=build-env /usr/share/zoneinfo /usr/share/zoneinfo
COPY --from=build-env /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=build-env /myapp/bin/app /myapp/
COPY --from=build-env /myapp/bin/migrate /myapp/
USER 65532:65532
CMD ["/myapp/app"]