-
Notifications
You must be signed in to change notification settings - Fork 117
Expand file tree
/
Copy pathDockerfile
More file actions
80 lines (58 loc) · 2.21 KB
/
Dockerfile
File metadata and controls
80 lines (58 loc) · 2.21 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
# OpenHamClock Dockerfile
# Multi-stage build for optimized production image
# ============================================
# Stage 1: Build Frontend
# ============================================
FROM node:22-alpine AS builder
WORKDIR /app
# Copy package files
COPY package*.json ./
# Install ALL dependencies (including devDependencies for Vite)
RUN npm install
# Copy source files
COPY . .
# Ensure public/ exists (may not be tracked in git)
RUN mkdir -p /app/public
# Download vendor assets for self-hosting (fonts, Leaflet — no external CDN at runtime)
RUN apk add --no-cache curl && bash scripts/vendor-download.sh || true
# Build the React app with Vite
RUN npm run build
# ============================================
# Stage 2: Production
# ============================================
FROM node:22-alpine AS production
# Set environment
ENV NODE_ENV=production
ENV PORT=3000
ENV NODE_OPTIONS="--max-old-space-size=2048 --expose-gc"
WORKDIR /app
# Create /data directory for persistent stats (Railway volume mount point)
RUN mkdir -p /data
# Copy package files and install production deps only
COPY package*.json ./
RUN npm install --omit=dev
# Copy server files
COPY server.js ./
COPY server/ ./server/
COPY config.js ./
COPY src/server ./src/server
# Copy WSJT-X relay agent (served as download to users)
COPY wsjtx-relay ./wsjtx-relay
# Copy Rig Listener agent (served as download to users)
COPY rig-listener/rig-listener.js ./rig-listener/rig-listener.js
# Copy built frontend from builder stage
COPY --from=builder /app/dist ./dist
# Copy public folder from builder (for monolithic fallback reference)
# Using builder stage because public/ may not be separately available in production context
COPY --from=builder /app/public ./public
# Create local data directory as fallback
RUN mkdir -p /app/data
# Expose ports (3000 = web, 2237 = WSJT-X UDP, 12060 = N1MM/DXLog)
EXPOSE 3000
EXPOSE 2237/udp
EXPOSE 12060
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://127.0.0.1:3000/api/health || exit 1
# Start server with explicit heap limit and GC access for periodic compaction
CMD ["node", "--max-old-space-size=2048", "--expose-gc", "server.js"]