-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
59 lines (47 loc) · 1.26 KB
/
Dockerfile
File metadata and controls
59 lines (47 loc) · 1.26 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
# Build stage
FROM node:20-alpine AS builder
WORKDIR /app
# Copy package files
COPY package.json pnpm-lock.yaml* package-lock.json* yarn.lock* ./
# Install dependencies
# pnpm이 있으면 pnpm 사용, 없으면 npm 사용
RUN if [ -f pnpm-lock.yaml ]; then \
npm install -g pnpm && \
pnpm install --frozen-lockfile; \
elif [ -f yarn.lock ]; then \
npm install -g yarn && \
yarn install --frozen-lockfile; \
else \
npm ci; \
fi
# Copy source code
COPY . .
# Build application
RUN if [ -f pnpm-lock.yaml ]; then \
pnpm run build; \
elif [ -f yarn.lock ]; then \
yarn build; \
else \
npm run build; \
fi
# Production stage
FROM node:20-alpine
WORKDIR /app
# Copy package files
COPY package.json pnpm-lock.yaml* package-lock.json* yarn.lock* ./
# Install production dependencies only
RUN if [ -f pnpm-lock.yaml ]; then \
npm install -g pnpm && \
pnpm install --prod --frozen-lockfile; \
elif [ -f yarn.lock ]; then \
npm install -g yarn && \
yarn install --prod --frozen-lockfile; \
else \
npm ci --only=production; \
fi
# Copy built application from builder
COPY --from=builder /app/dist ./dist
# Expose port
EXPOSE 3000
# Start application
CMD ["node", "dist/main.js"]