forked from gardener/dashboard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
75 lines (53 loc) · 2.3 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
# SPDX-FileCopyrightText: 2021 SAP SE or an SAP affiliate company and Gardener contributors
#
# SPDX-License-Identifier: Apache-2.0
#### Builder ####
FROM node:16-alpine3.15 as builder
WORKDIR /usr/src/app
COPY . .
# validate zero-installs project and disable network
RUN yarn config set enableNetwork false
RUN yarn install --immutable --immutable-cache
# check that the constraints are met
RUN yarn constraints
# run lint in all workspaces
RUN yarn workspace @gardener-dashboard/logger run lint
RUN yarn workspace @gardener-dashboard/request run lint
RUN yarn workspace @gardener-dashboard/kube-config run lint
RUN yarn workspace @gardener-dashboard/kube-client run lint
RUN yarn workspace @gardener-dashboard/backend run lint
RUN yarn workspace @gardener-dashboard/frontend run lint
# run test in all workspaces
RUN yarn workspace @gardener-dashboard/logger run test-coverage
RUN yarn workspace @gardener-dashboard/request run test-coverage
RUN yarn workspace @gardener-dashboard/kube-config run test-coverage
RUN yarn workspace @gardener-dashboard/kube-client run test-coverage
RUN yarn workspace @gardener-dashboard/backend run test-coverage
RUN yarn workspace @gardener-dashboard/frontend run test-coverage
# bump backend and frontend version
RUN yarn workspace @gardener-dashboard/backend version "$(cat VERSION)"
RUN yarn workspace @gardener-dashboard/frontend version "$(cat VERSION)"
# run backend production install
RUN yarn workspace @gardener-dashboard/backend prod-install --pack /usr/src/build
# run frontend build
RUN yarn workspace @gardener-dashboard/frontend run build
# copy files to production directory
RUN cp -r frontend/dist /usr/src/build/public \
&& find /usr/src/build/.yarn -mindepth 1 -name cache -prune -o -exec rm -rf {} +
#### Release ####
FROM alpine:3.15 as release
RUN addgroup -g 1000 node && adduser -u 1000 -G node -s /bin/sh -D node
RUN apk add --no-cache tini libstdc++
WORKDIR /usr/src/app
ENV NODE_ENV "production"
ARG PORT=8080
ENV PORT $PORT
# copy node binary
COPY --from=builder /usr/local/bin/node /usr/local/bin/
# copy production directory
COPY --chown=node:node --from=builder /usr/src/build .
USER node
EXPOSE $PORT
VOLUME ["/home/node"]
ENTRYPOINT [ "/sbin/tini", "--", "node", "--require=/usr/src/app/.pnp.js"]
CMD ["server.js"]