-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
60 lines (41 loc) · 1.39 KB
/
Dockerfile
File metadata and controls
60 lines (41 loc) · 1.39 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
# ============================================
# Stage 1: Build
# ============================================
FROM node:22-alpine AS builder
RUN npm install -g pnpm
WORKDIR /app
# Copy package files first (better layer caching)
COPY package.json pnpm-lock.yaml* ./
# Install ALL dependencies (need devDeps for TypeScript)
RUN pnpm install --frozen-lockfile || pnpm install
# Copy source and build
COPY tsconfig.json ./
COPY src ./src
RUN pnpm build
# Install production deps in separate directory for clean copy
RUN pnpm install --prod --frozen-lockfile || pnpm install --prod
# ============================================
# Stage 2: Production (minimal alpine)
# ============================================
FROM node:22-alpine
# Install curl for healthchecks
RUN apk add --no-cache curl ca-certificates
WORKDIR /app
# Copy production node_modules from builder
COPY --from=builder /app/node_modules ./node_modules
# Copy compiled JavaScript
COPY --from=builder /app/dist ./dist
# Copy package.json for module resolution
COPY package.json ./
# Create data directory for test files
RUN mkdir -p ./data
ENV NODE_ENV=production
ENV PORT=3000
ENV HOST=0.0.0.0
ENV DATA_DIR=/app/data
EXPOSE 3000
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD curl -f http://localhost:3000/health || exit 1
ARG BUILD_VERSION=1.0.0
ENV BUILD_VERSION=${BUILD_VERSION}
CMD ["node", "dist/index.js"]