-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
53 lines (36 loc) · 1.1 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
53
# syntax=docker/dockerfile:1
# ---- Builder ----
FROM --platform=$BUILDPLATFORM node:20-alpine3.16 AS builder
RUN mkdir /build
WORKDIR /build
COPY package.json .
COPY pnpm-lock.yaml .
RUN apk add --update --no-cache git
RUN npm install -g pnpm@8
RUN pnpm install --frozen-lockfile
COPY . .
RUN pnpm run generate
RUN pnpm run build
# ---- Dependencies ----
FROM --platform=$BUILDPLATFORM node:20-alpine3.16 AS deps
WORKDIR /deps
COPY package.json .
COPY pnpm-lock.yaml .
COPY ./prisma .
RUN apk add --update --no-cache git
RUN npm install -g pnpm@8
RUN pnpm install --frozen-lockfile --prod --no-optional
RUN pnpm dlx prisma generate
# ---- Runner ----
FROM --platform=$BUILDPLATFORM node:20-alpine3.16
RUN apk add --update --no-cache dumb-init git
RUN npm install -g pnpm@8
WORKDIR /app
COPY --from=builder /build/package.json ./package.json
COPY --from=builder /build/pnpm-lock.yaml ./pnpm-lock.yaml
COPY --from=deps /deps/node_modules ./node_modules
COPY --from=builder /build/prisma ./prisma
COPY --from=builder /build/dist ./dist
USER node
ENTRYPOINT ["dumb-init", "--"]
CMD ["sh", "-c", "pnpm run start"]