-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
55 lines (41 loc) · 1.09 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
54
55
#
# Base layer
#
FROM node:20.5.0 as base
RUN npm install -g pnpm
#
# Dependencies layer
#
# FROM base as dependencies
FROM base as dependencies
# RUN apk add make g++ python3 git
RUN npm install -g pnpm node-gyp
WORKDIR /app
COPY tsconfig*.json ./
COPY package*.json pnpm-lock.yaml ./
# Install dependencies from pnpm-lock.yaml, see https://docs.npmjs.com/cli/v7/commands/npm-ci
RUN --mount=type=cache,target=/app/node_modules pnpm install --frozen-lockfile
#
# Building layer
#
FROM base as build
WORKDIR /app
COPY . .
RUN --mount=type=cache,target=/app/node_modules pnpm install --frozen-lockfile
# Build application (produces dist/ folder)
RUN --mount=type=cache,target=/app/node_modules pnpm dlx prisma generate
RUN --mount=type=cache,target=/app/node_modules pnpm build
RUN pnpm prune --prod
#
# Runtime layer
#
FROM base as production
WORKDIR /app
COPY package*.json pnpm-lock.yaml ./
COPY --from=build /app/node_modules/ ./node_modules/
COPY --from=build /app/dist/ ./dist/
COPY .env ./
# Expose application port
EXPOSE 3000
# Start application
CMD [ "node", "dist/main.js" ]