-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.api.production
More file actions
66 lines (43 loc) · 2.04 KB
/
Copy pathDockerfile.api.production
File metadata and controls
66 lines (43 loc) · 2.04 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
FROM node:lts-slim AS builder
LABEL maintainer="hello@tillertech.io"
LABEL org.opencontainers.image.source = "https://github.com/Tillertech/foundry"
WORKDIR /foundry
RUN apt-get update && \
apt-get install -y --no-install-recommends python3 make g++ openssl && \
rm -rf /var/lib/apt/lists/*
COPY package.json package-lock.json ./
RUN npm ci --legacy-peer-deps
COPY . .
ENV NX_DAEMON=false
RUN npx prisma generate --config=apps/api/prisma.config.ts && \
npx nx build api --configuration=production
# Runtime dependencies are installed (and native addons like bcrypt compiled) in
# an isolated stage so the C/C++ toolchain never lands in the final image.
FROM node:lts-slim AS deps
WORKDIR /app
RUN apt-get update && \
apt-get install -y --no-install-recommends python3 make g++ openssl && \
rm -rf /var/lib/apt/lists/*
# nx emits a package.json listing only runtime deps for the webpack bundle.
COPY --from=builder /foundry/dist/apps/api/package.json ./package.json
# @prisma/client ships the query-compiler runtime the bundled client requires;
# prisma CLI is used by `migrate deploy` at container start.
RUN npm install --omit=dev --legacy-peer-deps && \
npm install --no-save --legacy-peer-deps prisma@^7.8.0 @prisma/client@^7.8.0 && \
npm cache clean --force
FROM node:lts-slim AS runner
LABEL maintainer="hello@tillertech.io"
WORKDIR /app
ENV NODE_ENV=production
RUN apt-get update && \
apt-get install -y --no-install-recommends openssl && \
rm -rf /var/lib/apt/lists/*
COPY --from=deps /app/node_modules ./node_modules
COPY --from=builder /foundry/dist/apps/api ./
# Prisma schema/migrations for `migrate deploy`, and mail templates which the
# mailer resolves relative to the bundle directory in production.
COPY --from=builder /foundry/apps/api/prisma ./prisma
COPY --from=builder /foundry/apps/api/prisma.config.ts ./prisma.config.ts
COPY --from=builder /foundry/apps/api/src/notification/mail/templates ./mail/templates
EXPOSE 3000
CMD ["sh", "-c", "npx prisma migrate deploy --config=prisma.config.ts && node main.js"]