-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
65 lines (50 loc) · 2.61 KB
/
Copy pathDockerfile
File metadata and controls
65 lines (50 loc) · 2.61 KB
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
# syntax=docker/dockerfile:1.7
# ─────────────────────────────────────────────────────────────────────────────
# Multi-stage Dockerfile for dexignation-api.
# Stage 1 builds TypeScript and generates the Prisma client.
# Stage 2 ships only the runtime artifacts.
#
# 멀티스테이지 Dockerfile. 1단계는 TypeScript 빌드 + Prisma 클라이언트 생성.
# 2단계는 런타임 산출물만 담은 가벼운 이미지.
# ─────────────────────────────────────────────────────────────────────────────
# ── Stage 1: build ──────────────────────────────────────────────────────────
FROM node:22-bookworm-slim AS build
WORKDIR /app
# Install build deps required by some native modules.
# 일부 네이티브 모듈에 필요한 빌드 의존성 설치.
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
openssl \
&& rm -rf /var/lib/apt/lists/*
COPY package*.json ./
COPY prisma ./prisma
RUN npm ci
COPY tsconfig.json ./
COPY src ./src
RUN npx prisma generate
RUN npm run build
# Prune devDependencies for a small runtime image.
# 런타임 이미지를 작게 하기 위해 dev 의존성 제거.
RUN npm prune --omit=dev
# ── Stage 2: runtime ────────────────────────────────────────────────────────
FROM node:22-bookworm-slim AS runtime
ENV NODE_ENV=production
ENV PORT=3000
WORKDIR /app
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
openssl \
tini \
&& rm -rf /var/lib/apt/lists/*
# Non-root user.
# 비루트 유저로 실행.
RUN useradd --uid 10001 --user-group --create-home --shell /bin/bash dexignation
USER dexignation:dexignation
COPY --chown=dexignation:dexignation --from=build /app/node_modules ./node_modules
COPY --chown=dexignation:dexignation --from=build /app/dist ./dist
COPY --chown=dexignation:dexignation --from=build /app/prisma ./prisma
COPY --chown=dexignation:dexignation --from=build /app/package.json ./package.json
EXPOSE 3000
# tini reaps zombies in container PID 1. / tini가 PID 1에서 좀비 프로세스를 정리.
ENTRYPOINT ["/usr/bin/tini", "--"]
CMD ["node", "dist/server.js"]