-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile-Api
48 lines (34 loc) · 1.18 KB
/
Dockerfile-Api
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
# base node image
FROM node:16-bullseye-slim as base
# Install dependencies
RUN apt-get update && apt-get install -y openssl make g++ gcc python3
RUN npm --silent install --global --depth 0 pnpm nx prisma
# set for base and all that inherit from it
ENV NODE_ENV=production
# Install all node_modules, including dev dependencies
FROM base as deps
RUN mkdir /app
WORKDIR /app
ADD ./package.json ./pnpm-lock.yaml ./
ADD ./libs/backend/database/model/schema.prisma ./libs/backend/database/model/schema.prisma
RUN pnpm i --prod=false
# Build the app
FROM base as build
RUN mkdir /app
WORKDIR /app
COPY --from=deps /app/node_modules /app/node_modules
ADD . .
RUN NX_DAEMON=false pnpm nx run back-api-app:build:production
# Finally, build the production image with minimal footprint
FROM base
ENV NODE_ENV=production
RUN mkdir /app
WORKDIR /app
COPY --from=deps /app/node_modules /app/node_modules
COPY --from=build /app/node_modules/@prisma /app/node_modules/@prisma
COPY --from=build /app/node_modules/.pnpm /app/node_modules/.pnpm
COPY --from=build /app/dist /app/dist
ADD . .
COPY ./apps/api/start-with-migrations.sh /
RUN chmod +x /start-with-migrations.sh
ENTRYPOINT ["/start-with-migrations.sh"]