-
Notifications
You must be signed in to change notification settings - Fork 9
/
Dockerfile.web
47 lines (38 loc) · 1.37 KB
/
Dockerfile.web
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
# SUPER IMPORTANT: NODE_OPTIONS="--v8-pool-size=1"
# A pod running in our openshift cluster, will report a ridiculous amount of cpu's available, as
# it's reporting on the underlying hardware. Node, in it's wisdom, will try to scale to using a
# huge amount of cpu's, which in turn results in massive memory usage. It's very important to limit
# the cpu pool size to something realistic.
ARG NODE_OPTIONS="--v8-pool-size=4"
# PHASE 1 - build frontend.
FROM docker.io/library/node:20-alpine AS static
# Switch to root user for package installs
USER 0
WORKDIR /app
COPY web/package.json .
COPY web/yarn.lock .
COPY web/.yarnrc.yml .
# do install first so it will be cached
RUN corepack enable \
&& yarn set version berry \
&& CYPRESS_INSTALL_BINARY=0 yarn install --immutable
COPY web .
RUN yarn run build:prod
# PHASE 2 - prepare hosting.
FROM docker.io/library/nginx:stable-alpine
# Copy application sources
COPY ./openshift/nginx.conf /etc/nginx/nginx.conf
# Copy the static content:
COPY --from=static /app/build .
RUN mkdir -p /tmp/nginx/client_temp
RUN chmod -R 755 /tmp/nginx
RUN mkdir -p /var/cache/nginx/proxy_temp
RUN mkdir -p /var/cache/nginx/fastcgi_temp
RUN mkdir -p /var/cache/nginx/uwsgi_temp
RUN mkdir -p /var/cache/nginx/scgi_temp
RUN chmod -R 755 /var/cache/nginx/
RUN chmod -R 755 /var/run
# Switch back to default user
USER 1001
EXPOSE 3000
CMD nginx -g "daemon off;"