-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
52 lines (48 loc) · 1.27 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
# ---- Base Node ----
FROM alpine:3.18.0 AS base
# install node
RUN apk add --no-cache nodejs-current npm tini git
# set working directory
WORKDIR /app
# Set tini as entrypoint
ENTRYPOINT ["/sbin/tini", "--"]
# copy project file
COPY package.json .
#
# ---- Dependencies ----
FROM base AS dependencies
# install node packages
RUN npm set progress=false && npm config set depth 0
RUN npm install --only=production
# copy production node_modules aside
RUN cp -R node_modules prod_node_modules
# install ALL node_modules, including 'devDependencies'
RUN npm install
#
# ---- Test ----
FROM dependencies AS test
COPY src ./src
COPY tsconfig.json squirrelly.js jest.config.cjs .eslintrc.json .env.test /app/
RUN npm run lint
# RUN npm run test
#
# ---- Build ----
FROM dependencies AS build
COPY src ./src
COPY tsconfig.json squirrelly.js jest.config.cjs .eslintrc.json .env.test /app/
RUN npm run build
#
# ---- Release ----
FROM base AS release
# copy production node_modules
COPY --from=dependencies /app/prod_node_modules ./node_modules
# copy app dist
COPY --from=build /app/dist /app/dist
# copy app extras
COPY tsconfig.json squirrelly.js /app/
COPY patches /app/patches
COPY locales /app/locales
COPY assets /app/assets
# expose port and define CMD
EXPOSE 3000
CMD node /app/dist/main.cjs