-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
29 lines (20 loc) · 859 Bytes
/
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
############################
# STEP 1 build executable binary
############################
FROM golang:1.12-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 tzdata && update-ca-certificates
RUN adduser -D -g '' appuser
WORKDIR $GOPATH/src/github.com/evzpav/documents-crud-refactored/
COPY . .
RUN CGO_ENABLED=0 GOOS=linux go build -o /go/bin/documents-crud-refactored ./cmd/server/main.go
############################
# STEP 2 build a small image
############################
FROM scratch
COPY --from=builder /etc/passwd /etc/passwd
COPY --from=builder /go/bin/documents-crud-refactored /go/bin/documents-crud-refactored
USER appuser
ENTRYPOINT ["/go/bin/documents-crud-refactored"]