-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
98 lines (77 loc) · 1.91 KB
/
Copy pathDockerfile
File metadata and controls
98 lines (77 loc) · 1.91 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# Build stage
FROM node:20-alpine AS builder
WORKDIR /app
# 타임존 설정
RUN apk add --no-cache tzdata \
&& cp /usr/share/zoneinfo/Asia/Seoul /etc/localtime \
&& echo "Asia/Seoul" > /etc/timezone
ENV TZ=Asia/Seoul
# Install dependencies for development and canvas build
# 기존 줄에서 py3-distutils 제거
RUN apk add --no-cache \
git \
python3 \
py3-pip \
py3-setuptools \
py3-wheel \
make \
g++ \
cairo-dev \
jpeg-dev \
pango-dev \
giflib-dev \
pixman-dev \
vips-dev
# Copy package files
COPY package*.json ./
# Install all dependencies (including dev dependencies for build)
RUN npm ci
# Copy source code
COPY . .
# Build the application
RUN npm run build
# Production stage
FROM node:20-alpine AS production
WORKDIR /app
# 타임존 설정
RUN apk add --no-cache tzdata \
&& cp /usr/share/zoneinfo/Asia/Seoul /etc/localtime \
&& echo "Asia/Seoul" > /etc/timezone
ENV TZ=Asia/Seoul
# Install dependencies for development and canvas build
# 기존 줄에서 py3-distutils 제거
RUN apk add --no-cache \
git \
python3 \
py3-pip \
py3-setuptools \
py3-wheel \
make \
g++ \
cairo-dev \
jpeg-dev \
pango-dev \
giflib-dev \
pixman-dev \
vips-dev
# Install dumb-init and curl for proper signal handling and health checks
RUN apk add --no-cache dumb-init curl
# Create non-root user
RUN addgroup -g 1001 -S nodejs
RUN adduser -S nestjs -u 1001
# Copy package files
COPY package*.json ./
# Install only production dependencies
RUN npm ci --only=production && npm cache clean --force
# Copy built application from builder stage
COPY --from=builder --chown=nestjs:nodejs /app/dist ./dist
# Switch to non-root user
USER nestjs
# Expose port
EXPOSE 3000
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD curl -f http://localhost:3000/health || exit 1
# Start the application
ENTRYPOINT ["dumb-init", "--"]
CMD ["node", "dist/main"]