-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
114 lines (86 loc) · 2.99 KB
/
Dockerfile
File metadata and controls
114 lines (86 loc) · 2.99 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# RuneBolt Production Dockerfile
# Multi-stage build for optimized production image
# Version: 1.0.0
# ============================================
# Stage 1: Dependencies
# ============================================
FROM node:20-alpine AS deps
# Install build dependencies for native modules
RUN apk add --no-cache python3 make g++ \
&& npm install -g npm@latest
WORKDIR /app
# Copy package files first (better layer caching)
COPY package*.json ./
# Install production dependencies only
RUN npm ci --only=production --ignore-scripts && npm cache clean --force
# ============================================
# Stage 2: Builder (TypeScript compilation)
# ============================================
FROM node:20-alpine AS builder
WORKDIR /app
# Install TypeScript
RUN npm install -g typescript
# Copy package files
COPY package*.json ./
COPY tsconfig.json ./
# Install all dependencies (including dev)
RUN npm ci --ignore-scripts
# Copy source code
COPY src ./src
# Build TypeScript
RUN tsc --build
# ============================================
# Stage 3: Production
# ============================================
FROM node:20-alpine AS production
# Security: Create non-root user
RUN addgroup -g 1001 -S runebolt && \
adduser -S runebolt -u 1001
# Install security updates and required packages
RUN apk update && \
apk upgrade && \
apk add --no-cache \
dumb-init \
wget \
ca-certificates && \
rm -rf /var/cache/apk/*
# Set working directory
WORKDIR /app
# Copy production dependencies from deps stage
COPY --from=deps /app/node_modules ./node_modules
COPY --from=deps /app/package*.json ./
# Copy compiled JavaScript from builder stage
COPY --from=builder /app/dist ./dist
# Create data directory for SQLite with proper permissions
RUN mkdir -p /data && \
chown -R runebolt:runebolt /data /app
# Switch to non-root user
USER runebolt
# Environment variables
ENV NODE_ENV=production \
PORT=3001 \
DATABASE_PATH=/data/runebolt.db \
UV_THREADPOOL_SIZE=128
# Expose port
EXPOSE 3001
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \
CMD wget --quiet --tries=1 --spider http://localhost:3001/health || exit 1
# Use dumb-init for proper signal handling
ENTRYPOINT ["dumb-init", "--"]
# Default command (can be overridden for workers)
CMD ["node", "dist/index.js"]
# ============================================
# Stage 4: Worker (alternative target)
# ============================================
FROM production AS worker
CMD ["node", "dist/worker.js"]
# ============================================
# Metadata
# ============================================
LABEL org.opencontainers.image.title="RuneBolt Backend" \
org.opencontainers.image.description="Bitcoin Layer 2 Payment Channel Hub" \
org.opencontainers.image.version="1.0.0" \
org.opencontainers.image.vendor="Bitmap Asset" \
org.opencontainers.image.source="https://github.com/bitmap-asset/runebolt" \
org.opencontainers.image.licenses="MIT"