-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
41 lines (31 loc) · 905 Bytes
/
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
# syntax=docker/dockerfile:1
ARG NODE_VERSION=20.11.1
# Setup the base image
FROM node:${NODE_VERSION}-alpine AS alpine
# Setup pnpm
FROM alpine AS base
RUN corepack enable
RUN pnpm config set store-dir ~/.pnpm-store
# Setup all the dependencies to build the project
FROM base AS dev-deps
WORKDIR /app
COPY package.json pnpm-lock.yaml ./
RUN --mount=type=cache,id=pnpm,target=~/.pnpm-store pnpm install --frozen-lockfile
# Setup only production dependencies
FROM base AS deps
WORKDIR /app
COPY package.json pnpm-lock.yaml ./
RUN --mount=type=cache,id=pnpm,target=~/.pnpm-store pnpm install --prod --frozen-lockfile
# Build the project
FROM dev-deps AS builder
ENV NODE_ENV=production
COPY . .
RUN pnpm build
# Run layer
FROM deps AS runner
WORKDIR /app
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 api
USER api
COPY --from=builder /app/build .
CMD [ "pnpm", "start" ]