-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
49 lines (37 loc) · 1.02 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
# Build a static Go app binary first
FROM golang:1.17 as builder
#RUN apk update && apk add --no-cache git
ENV USER=appuser
ENV UID=1001
RUN adduser \
--disabled-password \
--gecos "" \
--home "/nonexistent" \
--shell "/sbin/nologin" \
--no-create-home \
--uid "${UID}" \
"${USER}"
WORKDIR $GOPATH/src/app/
COPY ./chain ./chain
COPY ./config ./config
COPY ./util ./util
COPY ./go.* .
COPY main.go .
# fetch dependencies
RUN go mod download
RUN go mod tidy
RUN go mod verify
# strip debug data from the final build
RUN go build -ldflags="-s -w" -o /app/
RUN mkdir -p /app/conf && touch /app/conf/.keep && chown -R appuser:appuser /app
FROM gcr.io/distroless/base
USER appuser:appuser
# import user and group files from above
COPY --from=builder /etc/passwd /etc/passwd
COPY --from=builder /etc/group /etc/group
COPY --from=builder /app/tdameritrade-alerter /app/
COPY --from=builder /app/conf/.keep /app/conf/
USER appuser:appuser
VOLUME /app/conf
ENTRYPOINT ["/app/tdameritrade-alerter"]
CMD ["/app/conf"]