-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
65 lines (41 loc) · 1.25 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
56
57
58
59
60
61
62
63
64
65
FROM node:18-alpine AS base
FROM base AS pruner
# Prepare work directory
WORKDIR /app
# Prepare pnpm https://pnpm.io/installation#using-corepack
RUN corepack enable && \
corepack prepare --activate pnpm@latest
# Prepare deps
RUN apk add --no-cache libc6-compat
RUN apk update
RUN apk add git --no-cache
# Prepare build deps ( ignore postinstall scripts for now )
COPY . .
FROM base AS builder
WORKDIR /app
# Prepare pnpm https://pnpm.io/installation#using-corepack
RUN corepack enable && \
corepack prepare --activate pnpm@latest
# Prepare deps
RUN apk add --no-cache libc6-compat
RUN apk update
RUN apk add git --no-cache
# First install the dependencies (as they change less often)
COPY .gitignore .gitignore
COPY tsconfig.json tsconfig.json
COPY .npmrc .npmrc
COPY --from=pruner /app/pnpm-*.yaml ./
COPY --from=pruner ./app/ ./
RUN rm -rf ./node_modules
RUN --mount=type=cache,id=pnpm-store,target=/root/.local/share/pnpm/store pnpm install
# Build the project
RUN pnpm run build
FROM base AS runner
# ENV NODE_ENV=production
WORKDIR /app
RUN addgroup --system --gid 1001 server
RUN adduser --system --uid 1001 server
RUN chown -R server:server /app
COPY --from=builder --chown=server:server /app/ ./
USER server
CMD ["node", "dist/index.js"]