-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathDockerfile
41 lines (25 loc) · 841 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
ARG COLLECTOR_USER_UID=1000
#### Build executable binary ####
FROM mirror.gcr.io/library/golang:alpine AS builder
#hadolint ignore=DL3018
RUN apk update && apk add --no-cache git
ENV SRC_DIR=/tnf
ARG COLLECTOR_USER_UID
ARG COLLECTOR_USER=collectoruser
RUN adduser -D -u ${COLLECTOR_USER_UID} ${COLLECTOR_USER}
WORKDIR $SRC_DIR
COPY . .
# Fetch dependencies and Build the Go application
RUN go build
#### Build small image ####
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.10-1154
# Copy the user from the build image
COPY --from=builder /etc/passwd /etc/passwd
ARG COLLECTOR_USER_UID
USER ${COLLECTOR_USER_UID}
WORKDIR $SRC_DIR/collectoruser
# Copy the built app from the build image
COPY --from=builder /tnf/collector ./collector
EXPOSE 80
# Set the command to run when the container starts
ENTRYPOINT ["./collector"]