-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
43 lines (32 loc) · 1.01 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
# STEP 1 build executable binary
FROM golang:1.13.4-alpine3.10 as builder
# Install git
# RUN apk update && apk add git
RUN apk update && \
apk add --no-cache git ca-certificates && \
adduser -D -g '' amun
WORKDIR /amun
COPY go.mod go.sum ./
# get dependencies
#RUN go get -d -v
# Using go mod with go 1.11
RUN go mod download
RUN go mod verify
# Copy the source from the current directory to the Working Directory inside the container
COPY . .
# build the binary
# removing debug informations and compile only for linux target and disabling cross compilation
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -installsuffix cgo -ldflags="-w -s" -o amun
#RUN ls -la
# STEP 2 build a small image
# start from scratch
FROM scratch
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=builder /etc/passwd /etc/passwd
# expose yaml file
COPY --from=builder /amun/config.yaml /
# Copy our static executable
COPY --from=builder /amun/amun /
USER amun
EXPOSE 9000
ENTRYPOINT ["/amun"]