-
Notifications
You must be signed in to change notification settings - Fork 7
/
Dockerfile.openshift
71 lines (53 loc) · 1.98 KB
/
Dockerfile.openshift
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
ARG DOCKER_REGISTRY=docker.io/library
#####################
### Server Build Step
#####################
FROM --platform=${TARGETPLATFORM:-linux/amd64} $DOCKER_REGISTRY/golang:1.17-buster AS server-builder
RUN mkdir /server
WORKDIR /server
COPY fider/go.mod fider/go.sum ./
RUN go mod download
COPY fider .
ARG COMMITHASH
RUN sed -i -e '/auth :=/d' \
-e 's/servername, smtpConfig.EnableStartTLS, auth, email/servername, false, nil, email/g' \
-e 's/Config{ServerName: host}/Config{InsecureSkipVerify: true, ServerName: host}/g' \
app/services/email/smtp/smtp.go && \
COMMITHASH=${COMMITHASH} GOOS=${TARGETOS} GOARCH=${TARGETARCH} make build-server
#################
### UI Build Step
#################
FROM --platform=${TARGETPLATFORM:-linux/amd64} $DOCKER_REGISTRY/node:16-buster AS ui-builder
WORKDIR /ui
COPY fider/package.json fider/package-lock.json ./
RUN npm ci
RUN npx browserslist@latest --update-db
COPY fider .
# Override SMTP TLS
RUN sed -i -e '/auth :=/d' \
-e 's/servername, smtpConfig.EnableStartTLS, auth, email/servername, false, nil, email/g' \
-e 's/Config{ServerName: host}/Config{InsecureSkipVerify: true, ServerName: host}/g' \
app/services/email/smtp/smtp.go
RUN make build-ssr
RUN make build-ui
################
### Runtime Step
################
FROM --platform=${TARGETPLATFORM:-linux/amd64} $DOCKER_REGISTRY/debian:buster-slim
RUN apt-get update
RUN apt-get install -y ca-certificates
WORKDIR /app
COPY --from=server-builder /server/migrations /app/migrations
COPY --from=server-builder /server/views /app/views
COPY --from=server-builder /server/locale /app/locale
COPY --from=server-builder /server/LICENSE /app
COPY --from=server-builder /server/fider /app
COPY --from=ui-builder /ui/favicon.png /app
COPY --from=ui-builder /ui/dist /app/dist
COPY --from=ui-builder /ui/robots.txt /app
COPY --from=ui-builder /ui/ssr.js /app
EXPOSE 3000
HEALTHCHECK --timeout=5s CMD ./fider ping
CMD ./fider migrate && ./fider
# BC Gov: Set non-root user
# USER 1001