-
Notifications
You must be signed in to change notification settings - Fork 110
/
Dockerfile
39 lines (29 loc) · 947 Bytes
/
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
###################
# BUILDER
###################
FROM node:18-alpine AS build
WORKDIR /usr/src/app
# Copy and build NestJS server project
COPY --chown=node:node package*.json ./
COPY --chown=node:node tsconfig.build.json ./
COPY --chown=node:node tsconfig.json ./
COPY --chown=node:node nest-cli.json ./
COPY --chown=node:node .env ./
COPY --chown=node:node src ./src
ENV NPM_CONFIG_LOGLEVEL=error
RUN npm ci --no-audit
RUN npm run build
RUN npm run migration:up
RUN npm prune --production
USER node
###################
# PRODUCTION
###################
FROM node:18-alpine AS production
WORKDIR /usr/src/app
COPY --chown=node:node .env ./
COPY --chown=node:node --from=build /usr/src/app/node_modules ./node_modules
COPY --chown=node:node --from=build /usr/src/app/package*.json ./
COPY --chown=node:node --from=build /usr/src/app/test.db ./
COPY --chown=node:node --from=build /usr/src/app/dist ./dist
CMD ["npm", "run", "start:prod"]