-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathDockerfile
More file actions
66 lines (46 loc) · 1.74 KB
/
Dockerfile
File metadata and controls
66 lines (46 loc) · 1.74 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
# Multi-stage build for Radar
# Stage 1: Build everything (using monorepo structure)
FROM node:20-slim AS builder
WORKDIR /app
# Install build dependencies for native modules (like DuckDB)
RUN apt-get update && apt-get install -y --no-install-recommends python3 make g++ && rm -rf /var/lib/apt/lists/*
# Copy root package files and workspace configs
COPY package*.json ./
COPY client/package*.json ./client/
COPY server/package*.json ./server/
# Install all dependencies (respects workspace structure)
RUN npm ci
# Copy source code for both client and server
COPY client/ ./client/
COPY server/ ./server/
# Build client
RUN npm run build:client
# Build server
RUN npm run build:server
# Stage 2: Production image
FROM node:20-slim
WORKDIR /app
# Copy package files for structure
COPY package*.json ./
COPY server/package*.json ./server/
# Copy node_modules from builder (includes compiled DuckDB)
# This avoids rebuilding native modules in production
COPY --from=builder /app/node_modules ./node_modules
# Copy built server from builder
COPY --from=builder /app/server/dist ./dist
# Copy built client from builder (to be served by Express)
COPY --from=builder /app/client/dist ./public
# Copy server source files that might be needed at runtime
COPY --from=builder /app/server/src/news_feeds.json ./
# Copy static data files
COPY --from=builder /app/server/src/Data/military-bases.kml ./Data/military-bases.kml
RUN mkdir -p ./Data
# Expose port
EXPOSE 3001
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=40s --retries=3 \
CMD node -e "require('http').get('http://localhost:3001/health', (r) => {process.exit(r.statusCode === 200 ? 0 : 1)})"
# Set NODE_ENV
ENV NODE_ENV=production
# Run the application
CMD ["node", "dist/index.js"]