-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDockerfile.history-scanner
More file actions
65 lines (47 loc) · 1.81 KB
/
Dockerfile.history-scanner
File metadata and controls
65 lines (47 loc) · 1.81 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
# Multi-stage build for history scanner microservice
FROM node:22-alpine AS builder
# Set working directory
WORKDIR /app
# Install pnpm
RUN npm install -g pnpm@10.12.1
# Copy package files
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
COPY apps/history-scanner/package.json ./apps/history-scanner/
COPY packages/*/package.json ./packages/*/
# Install dependencies
RUN pnpm install --frozen-lockfile
# Copy source code
COPY . .
# Build the application
RUN pnpm build:ts
# Production stage
FROM node:22-alpine AS runtime
# Create app user
RUN addgroup -g 1001 -S nodejs && \
adduser -S stellaratlas -u 1001
# Set working directory
WORKDIR /app
# Install pnpm
RUN npm install -g pnpm@10.12.1
# Copy package files
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
COPY apps/history-scanner/package.json ./apps/history-scanner/
COPY packages/*/package.json ./packages/*/
# Install production dependencies only
RUN pnpm install --frozen-lockfile --prod
# Copy built application from builder stage
COPY --from=builder --chown=stellaratlas:nodejs /app/apps/history-scanner/lib ./apps/history-scanner/lib
COPY --from=builder --chown=stellaratlas:nodejs /app/packages/*/lib ./packages/*/lib
COPY --from=builder --chown=stellaratlas:nodejs /app/apps/history-scanner/src ./apps/history-scanner/src
COPY --from=builder --chown=stellaratlas:nodejs /app/packages/*/src ./packages/*/src
# Create logs directory
RUN mkdir -p /app/logs && chown stellaratlas:nodejs /app/logs
# Switch to non-root user
USER stellaratlas
# Expose port
EXPOSE 3001
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD node -e "http.get('http://localhost:3001/health', (res) => { process.exit(res.statusCode === 200 ? 0 : 1) })"
# Start the application
CMD ["pnpm", "--filter", "history-scanner", "run", "scan-history"]