-
Notifications
You must be signed in to change notification settings - Fork 0
/
dockerfile
53 lines (40 loc) · 1.21 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
###################
# BUILD FOR LOCAL DEVELOPMENT
###################
FROM node:20-alpine as development
WORKDIR /app
RUN npm install -g pnpm
######################
#BUILD FOR PRODUCTION#
######################
FROM development as build
WORKDIR /app
COPY ./ ./
ENV NPM_CONFIG_LOGLEVEL warn
ENV NODE_ENV=PRODUCTION
# Copy pnpm from development stage
COPY --from=development /usr/local/lib/node_modules/pnpm /usr/local/lib/node_modules/pnpm
# Install app dependencies
RUN pnpm install --frozen-lockfile
RUN npx ts-patch install
RUN pnpm run prebuild
RUN pnpm run build
RUN mkdir -p /app/packages/api
RUN npx nestia swagger
RUN pnpm prune --prod
RUN pnpm db:pull
RUN pnpm db:generate
USER node
######################
#BUILD FOR PRODUCTION#
######################
FROM development as production
COPY --chown=node:node --from=build /app/dist /app/dist
COPY --chown=node:node --from=build /app/node_modules /app/node_modules
COPY --chown=node:node --from=build /app/.env /app/.env
COPY --chown=node:node --from=build /app/packages /app/packages
COPY --chown=node:node --from=build /app/package.json /app/package.json
RUN mkdir -p /app/logs && chown node:node /app/logs
USER node
CMD [ "pnpm", "run", "start:prod" ]
EXPOSE 8000