-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
64 lines (45 loc) · 1.69 KB
/
Dockerfile
File metadata and controls
64 lines (45 loc) · 1.69 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
# Multi-stage build를 사용하여 최적화
# Stage 1: 빌드 단계
FROM node:20-alpine AS builder
WORKDIR /app
# 패키지 파일 복사
COPY package*.json ./
COPY prisma.config.ts ./
# 의존성 설치 (devDependencies 포함)
RUN npm ci
# 소스 코드 복사
COPY . .
# Prisma Client 생성
RUN npx prisma generate
# TypeScript 빌드
RUN npm run build
# Stage 2: 프로덕션 단계
FROM node:20-alpine
WORKDIR /app
# 프로덕션 의존성만 설치
COPY package*.json ./
COPY prisma.config.ts ./
RUN npm ci --only=production && npm cache clean --force
# Prisma 관련 파일 복사
# Prisma CLI도 필요하므로 (마이그레이션 실행용) 빌더에서 복사
COPY --from=builder /app/node_modules/.prisma ./node_modules/.prisma
COPY --from=builder /app/node_modules/@prisma ./node_modules/@prisma
COPY --from=builder /app/node_modules/prisma ./node_modules/prisma
COPY --from=builder /app/prisma ./prisma
# 빌드된 애플리케이션 복사
COPY --from=builder /app/dist ./dist
# 프롬프트 파일 복사 (런타임에 필요)
# __dirname은 dist/src/ai/llm.service.js를 가리키므로 prompts는 dist/src/ai/prompts에 있어야 함
COPY --from=builder /app/src/ai/prompts ./dist/src/ai/prompts
# Entrypoint 스크립트 복사 및 실행 권한 부여
COPY docker-entrypoint.sh ./
RUN chmod +x docker-entrypoint.sh
# 포트 노출
EXPOSE 3000
# 헬스체크 (선택사항)
HEALTHCHECK --interval=30s --timeout=3s --start-period=40s --retries=3 \
CMD node -e "require('http').get('http://localhost:3000/health', (r) => {process.exit(r.statusCode === 200 ? 0 : 1)})"
# Entrypoint 설정
ENTRYPOINT ["./docker-entrypoint.sh"]
# 애플리케이션 실행
CMD ["npm", "run", "start:prod"]