-
Notifications
You must be signed in to change notification settings - Fork 3
/
Dockerfile
79 lines (57 loc) · 1.76 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
## go backend
FROM docker.io/library/golang:1.17 as go
WORKDIR /temp
## install goimports
RUN go mod init temp
RUN go get golang.org/x/tools/cmd/[email protected] && go install golang.org/x/tools/cmd/goimports
# install golangci-lint
RUN wget -O- -nv https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.48.0 && \
mv ./bin/golangci-lint /bin/.
WORKDIR /src
COPY . .
RUN find . -type f
RUN make backend-lint
RUN make backend-build
#### shrink the lander golang binary
######## shrink the binaries
FROM docker.io/hairyhenderson/upx:3.94 as upx
WORKDIR /src
COPY --from=go /src/lander .
RUN upx lander
## build front
FROM docker.io/library/node:16.13.2 as node
# This step produces /src/frontend/dist which we will COPY into the final docker image
WORKDIR /src
COPY . .
RUN make frontend-lint
RUN make frontend-build
## pull it all together
FROM docker.io/library/alpine
RUN apk --no-cache add ca-certificates
WORKDIR /app
# Copy in the lander golang binary
COPY --from=upx /src/lander .
# Copy in the "dist" folder from the node stage
COPY --from=node /src/frontend/dist /app/frontend/dist
## show us the size just for the observability
RUN find /app -type d -exec du -sh {} \; ; du -sh /app/lander
## create a non-root user
ENV USER=app
ENV UID=1000
ENV GID=1000
# add the group+user called $USER
# NOTE $HOME is being set to /tmp so your shell history isn't stored in the docroot (in case u kubectl exec into the pod)
RUN addgroup -g "$GID" "$USER" && \
adduser \
--disabled-password \
--gecos "" \
--home "/tmp" \
--ingroup "$USER" \
--uid "$UID" \
"$USER"
# chown the files to be owned by $USER
RUN chown -R $UID:$GID /app
# set the container to run as $USER henceforth
USER $USER
# launch lander on start
ENTRYPOINT [ "./lander" ]