-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
39 lines (30 loc) · 1.12 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
############################
# Building executable binary
############################
# golang:1.12.7-alpine
#FROM golang@sha256:1121c345b1489bb5e8a9a65b612c8fed53c175ce72ac1c76cf12bbfc35211310 as builder
FROM golang:1.13-alpine as builder
# Install git + SSL ca certificates:
# - Git is required for fetching the dependencies
# - CA Certificates is required to call HTTPS endpoints
RUN apk update && apk add --no-cache git ca-certificates && update-ca-certificates
WORKDIR $GOPATH/src/application
COPY . .
ENV GO111MODULE=on
RUN go mod download
RUN go mod verify
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -o $GOPATH/bin/main
RUN chmod +x $GOPATH/bin/main
###############################
# Building a small Docker image
###############################
FROM scratch
# COPY --from=builder /go/src/application/config.yaml /
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=builder /etc/passwd /etc/passwd
COPY --from=builder /usr/local/go/lib/time/zoneinfo.zip /
ENV TZ=Europe/Paris
ENV ZONEINFO=/zoneinfo.zip
COPY --from=builder /go/bin/main /main
USER daemon
ENTRYPOINT ["/main"]