This repository has been archived by the owner on Feb 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
51 lines (43 loc) · 1.54 KB
/
Dockerfile
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
48
49
50
51
ARG go_version=1.17
# User
FROM alpine:3.13.1 as user
ARG uid=10001
ARG gid=10001
RUN echo "scratchuser:x:${uid}:${gid}::/home/scratchuser:/bin/sh" > /scratchpasswd
# Certs
FROM alpine:3.13.1 as certs
RUN apk add -U --no-cache ca-certificates
# Build
FROM golang:${go_version} as build
WORKDIR /code/
ENV GO111MODULE=on
ENV CGO_ENABLED=0
COPY go.mod go.sum ./
RUN go mod download
COPY ./cmd/ ./cmd/
COPY ./internal/ ./internal/
COPY ./pkg/ ./pkg/
RUN GOOS=linux GOARCH=amd64 go build -o ./bin/publisher ./cmd/publisher
RUN GOOS=linux GOARCH=amd64 go build -o ./bin/consumer ./cmd/consumer
RUN GOOS=linux GOARCH=amd64 go build -o ./bin/api ./cmd/api
RUN GOOS=linux GOARCH=amd64 go build -o ./bin/grpc ./cmd/grpc
FROM scratch as publisher
COPY --from=certs /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY --from=user /scratchpasswd /etc/passwd
COPY --from=build /code/bin/publisher .
ENTRYPOINT ["./publisher"]
FROM scratch as consumer
COPY --from=certs /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY --from=user /scratchpasswd /etc/passwd
COPY --from=build /code/bin/consumer .
ENTRYPOINT ["./consumer"]
FROM scratch as api
COPY --from=certs /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY --from=user /scratchpasswd /etc/passwd
COPY --from=build /code/bin/api .
ENTRYPOINT ["./api"]
FROM scratch as grpc
COPY --from=certs /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY --from=user /scratchpasswd /etc/passwd
COPY --from=build /code/bin/grpc .
ENTRYPOINT ["./grpc"]