-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
51 lines (41 loc) · 1.38 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
# Use an official Node.js runtime as a base image
FROM node:20.9.0-alpine AS base
FROM base AS builder
RUN apk add --no-cache libc6-compat
RUN apk update
# Set npm to a specific version
RUN npm install -g [email protected]
# Set working directory
WORKDIR /app
RUN npm install -g turbo@latest
COPY . .
# Generate a partial monorepo with a pruned lockfile for a target workspace.
RUN turbo prune @kaizen/api --docker
# Add lockfile and package.json's of isolated subworkspace
FROM base AS installer
RUN apk add --no-cache libc6-compat
RUN apk update
WORKDIR /app
# First install the dependencies (as they change less often)
COPY .gitignore .gitignore
COPY --from=builder /app/out/json/ .
COPY --from=builder /app/out/package-lock.json ./package-lock.json
# Build the project
COPY --from=builder /app/out/full/ .
COPY tsconfig.base.json .
RUN npm ci
RUN npx turbo run build --filter=@kaizen/api
FROM base AS runner
WORKDIR /app
# Copy the built files and install production dependencies
COPY --from=builder /app/out/json/ .
COPY --from=builder /app/out/package-lock.json ./package-lock.json
COPY --from=builder /app/out/full/apps/api/src/prisma ./apps/api/src/prisma
COPY --from=installer /app/dist/ .
RUN npm ci --omit=dev
RUN npx prisma generate
# Don't run production as root
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 expressjs
USER expressjs
CMD ["node", "apps/api/src/server.js"]