-
Notifications
You must be signed in to change notification settings - Fork 4
/
Dockerfile
43 lines (30 loc) · 892 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
42
43
#syntax=docker/dockerfile:1.12
FROM node:20.18.1-alpine3.19 AS base
# DEPS
FROM base AS deps
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk add --no-cache libc6-compat
WORKDIR /app
COPY --link .npmrc package.json package-lock.json ./
RUN npm ci
# BUILDER
FROM base AS builder
WORKDIR /app
# copy files
COPY --from=deps --link /app/node_modules ./node_modules
COPY --link . .
# build
RUN npm run build
# RUNNER
FROM base AS runner
WORKDIR /app
ENV NODE_ENV=production
RUN \
addgroup --system --gid 1001 nodejs; \
adduser --system --uid 1001 nodejs
COPY --link package.json ./
COPY --from=deps --link /app/node_modules ./node_modules
COPY --from=builder --link --chown=1001:1001 /app/dist ./dist
RUN npm prune --production
USER nodejs
CMD ["node", "dist/index.js"]