-
Notifications
You must be signed in to change notification settings - Fork 22
/
Dockerfile
42 lines (30 loc) · 932 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
30
31
32
33
34
35
36
37
38
39
40
41
42
# 1.17-alpine bug : standard_init_linux.go:228: exec user process caused: no such file or directory
ARG GOLANG_VERSION=1.17
# Building custom health checker
FROM golang:$GOLANG_VERSION as health-build-env
# Copying source
WORKDIR /go/src/app
COPY ./healthcheck /go/src/app
# Installing dependencies
RUN go get -d -v ./...
# Compiling
RUN go build -o /go/bin/healthchecker
# Building bouncer
FROM golang:$GOLANG_VERSION as build-env
# Copying source
WORKDIR /go/src/app
COPY . /go/src/app
# Installing dependencies
RUN go get -d -v ./...
# Compiling
RUN go build -o /go/bin/app
FROM gcr.io/distroless/base:nonroot
COPY --from=health-build-env --chown=nonroot:nonroot /go/bin/healthchecker /
COPY --from=build-env --chown=nonroot:nonroot /go/bin/app /
# Run as a non root user.
USER nonroot
# Using custom health checker
HEALTHCHECK --interval=10s --timeout=5s --retries=2\
CMD ["/healthchecker"]
# Run app
CMD ["/app"]