-
Notifications
You must be signed in to change notification settings - Fork 3
/
frontend.Dockerfile
52 lines (38 loc) · 1.42 KB
/
frontend.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
#----------------------------------------------------------#
# First stage: base image for building frontend app #
#----------------------------------------------------------#
FROM node:16-alpine as base
WORKDIR /build
# Copy package*.json files first in order to make best use of docker layer caching
COPY package*.json ./
COPY frontend/package*.json ./frontend/
COPY client-generated ./client-generated/
# copy rest of the files
COPY *.js ./
COPY frontend/tsconfig* ./frontend/
COPY frontend/*.cjs ./frontend/
COPY frontend/*.ts ./frontend/
COPY frontend/index.html ./frontend/
COPY frontend/public ./frontend/public/
COPY frontend/.env* ./frontend/
COPY frontend/src ./frontend/src/
RUN npm ci
#--------------------------------------------------------#
# Second stage: image to build and test node application #
#--------------------------------------------------------#
FROM base as build
ARG VITE_BACKEND_URL
# lint project
RUN npm run lint -w frontend
# build
RUN npm run build -w frontend
#--------------------------------------------#
# Third stage: image to run node application #
#--------------------------------------------#
FROM nginx:1-alpine
# copy static result of builder to the standard nginx webroot
COPY --from=build /build/frontend/build/ /usr/share/nginx/html
# use custom nginx config
COPY deployment/docker/frontend.Docker.nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]