-
Notifications
You must be signed in to change notification settings - Fork 3
/
Dockerfile.webapp
48 lines (39 loc) · 1.8 KB
/
Dockerfile.webapp
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
###
# BUILD STAGE
###
FROM node:16-alpine AS build
ENV NODE_ENV production
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
# python3, make, and g++ are needed for building node-gyp (itself required by a bunch of our dependencies)
RUN apk update && apk add --no-cache python3 make g++ libc6-compat
RUN mkdir -p \
/home/node/app/ \
/home/node/app/packages/api \
/home/node/app/packages/frontend/common \
/home/node/app/packages/frontend/ui \
/home/node/app/packages/frontend/webapp \
/home/node/app/packages/frontend/www \
&& chown -R node:node /home/node/app/
USER node
WORKDIR /home/node/app/
COPY --chown=node:node packages/frontend/www/package.json ./packages/frontend/www/
COPY --chown=node:node packages/frontend/ui/package.json ./packages/frontend/ui/
COPY --chown=node:node packages/frontend/webapp/package.json ./packages/frontend/webapp/
COPY --chown=node:node packages/api/package.json ./packages/api/
COPY --chown=node:node package.json yarn.lock .yarnrc.yml ./
COPY --chown=node:node .yarn ./.yarn/
RUN yarn install --silent && yarn cache clean
ADD --chown=node:node ./packages/frontend/common ./packages/frontend/common/
ADD --chown=node:node ./packages/frontend/ui ./packages/frontend/ui/
ADD --chown=node:node ./packages/frontend/webapp ./packages/frontend/webapp/
USER node
WORKDIR /home/node/app/packages/frontend/webapp
RUN yarn build
###
# PRODUCTION STAGE
###
FROM nginx:1.26.1-alpine AS production
COPY ./packages/frontend/webapp/docker/nginx-entrypoint.sh /
COPY ./packages/frontend/webapp/docker/nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=build --chown=nginx:nginx /home/node/app/packages/frontend/webapp/dist /usr/share/nginx/html
ENTRYPOINT [ "sh", "/nginx-entrypoint.sh" ]