-
Notifications
You must be signed in to change notification settings - Fork 50
Expand file tree
/
Copy pathDockerfile
More file actions
47 lines (35 loc) · 1.87 KB
/
Dockerfile
File metadata and controls
47 lines (35 loc) · 1.87 KB
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
39
40
41
42
43
44
45
46
47
# syntax=docker/dockerfile:1.7
# Builder image
FROM golang:1.24.13@sha256:d2d2bc1c84f7e60d7d2438a3836ae7d0c847f4888464e7ec9ba3a1339a1ee804 AS build
WORKDIR /build/control_plane/account_service
COPY --link app/common /build/control_plane/account_service/app/common
COPY --link --from=credit_system . ../../../libs/grpc_interfaces/src/grpc_interfaces/credit_system/go
COPY --link --from=account_service_grpc . ../../../libs/grpc_interfaces/src/grpc_interfaces/account_service/go
RUN --mount=type=cache,target=/go/pkg/mod/ \
--mount=type=bind,source=go.sum,target=go.sum \
--mount=type=bind,source=go.mod,target=go.mod \
go mod download -x
RUN --mount=type=cache,target=/go/pkg/mod/ \
--mount=type=bind,source=go.sum,target=go.sum \
--mount=type=bind,source=go.mod,target=go.mod \
--mount=type=bind,source=main.go,target=main.go \
--mount=type=bind,source=app,target=app \
CGO_ENABLED=0 go build -trimpath -mod=readonly -gcflags="all=-spectre=all" -asmflags="all=-spectre=all" -ldflags="all=-s -w" -a -o account_service .
# Save Go third party package licenses
RUN --mount=type=cache,target=/go/pkg/mod/ \
--mount=type=bind,source=go.sum,target=go.sum \
--mount=type=bind,source=go.mod,target=go.mod \
--mount=type=bind,source=main.go,target=main.go \
--mount=type=bind,source=app,target=app \
go install github.com/google/go-licenses@v1.0.0 && \
go-licenses save . --save_path /THIRD_PARTY_NOTICES || true
# Production image
FROM gcr.io/distroless/static-debian12:nonroot@sha256:a9329520abc449e3b14d5bc3a6ffae065bdde0f02667fa10880c49b35c109fd1 AS runtime
COPY --link --from=build /build/control_plane/account_service/account_service .
COPY --from=build /THIRD_PARTY_NOTICES /THIRD_PARTY_NOTICES
USER nonroot
ENV GRPC_SERVER_PORT=5001
EXPOSE $GRPC_SERVER_PORT
ENV GATEWAY_SERVER_PORT=5002
EXPOSE $GATEWAY_SERVER_PORT
ENTRYPOINT ["./account_service"]