-
Notifications
You must be signed in to change notification settings - Fork 1
/
backend.Dockerfile
51 lines (31 loc) · 1.18 KB
/
backend.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
FROM node:18.16.0 as build
WORKDIR /app
RUN npm install -g @nestjs/cli
COPY package*.json ./
COPY packages/backend/package*.json ./packages/backend/
COPY packages/shared/package*.json ./packages/shared/
RUN npm install
COPY . .
RUN npm run prisma:generate
RUN npm run shared:build
RUN npm run backend:build
FROM node:18.16.0
WORKDIR /app
# Copy build folders
COPY --from=build /app/packages/backend/dist /app/packages/backend/dist
COPY --from=build /app/packages/shared/dist /app/packages/shared/dist
# Copy package.json and package-lock.json files
COPY --from=build /app/package*.json /app/
COPY --from=build /app/packages/backend/package*.json /app/packages/backend/
COPY --from=build /app/packages/shared/package*.json /app/packages/shared/
COPY --from=build /app/packages/backend/prisma /app/packages/backend/prisma
# Copy .env configs
COPY --from=build /app/packages/backend/.env* /app/packages/backend/
# Install production dependencies for backend
RUN npm ci --omit=dev
# Generate prisma client
RUN npm run prisma:generate
COPY --from=build /app/node_modules/@my-monorepo/shared /app/node_modules/@my-monorepo/shared
# Export port
EXPOSE 3001
CMD ["npm", "run", "start:backend:prod"]