-
Notifications
You must be signed in to change notification settings - Fork 6
/
Dockerfile.client
36 lines (28 loc) · 1.52 KB
/
Dockerfile.client
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
#docker build -f Dockerfile.client -t gcr.io/project-id/tracking-client .
#docker run -d -p 50051:50051 --name tracking gcr.io/project-id/tracking-client
FROM golang:1.21 as builder
ARG TAG
ARG COMMIT
ADD tracking/api /go/src/tracking-client/api
ADD tracking/cmd/client /go/src/tracking-client/cmd/client
ADD tracking/google /go/src/tracking-client/google
ADD tracking/pkg /go/src/tracking-client/pkg
ADD internal/common /go/src/internal/common
ADD internal/datatypes /go/src/internal/datatypes
COPY tracking/go.mod tracking/go.sum /go/src/tracking-client/
WORKDIR /go/src/tracking-client
ENV GO111MODULE=on
RUN go mod tidy
RUN go mod download
RUN date +%FT%H:%I:%M+%Z > /tmp/date
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -trimpath -buildvcs=true -a -gcflags='all="-l"' -ldflags='-s -w -extldflags "-static" -X main.version='${TAG}' -X main.commit='${COMMIT}' -X main.date='$(cat /tmp/date) -o /go/bin/tracking-client /go/src/tracking-client/cmd/client/main.go
FROM gcr.io/distroless/static-debian11:nonroot
LABEL org.opencontainers.image.url='https://github.com/srinandan/sample-apps/tracking' \
org.opencontainers.image.documentation='https://github.com/srinandan/sample-apps' \
org.opencontainers.image.source='https://github.com/srinandan/sample-apps/tracking' \
org.opencontainers.image.vendor='Google LLC' \
org.opencontainers.image.licenses='Apache-2.0' \
org.opencontainers.image.description='A set of sample microservices'
COPY --from=builder /go/bin/tracking-client /
EXPOSE 8080
CMD [ "/tracking-client" ]