-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
93 lines (67 loc) · 2.32 KB
/
Dockerfile
File metadata and controls
93 lines (67 loc) · 2.32 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
# Multi-stage Dockerfile for OrgTree
# Supports both development and production builds
# ==============================================================================
# Base stage - shared between dev and prod
# ==============================================================================
FROM node:20-alpine AS base
WORKDIR /app
# Install build dependencies for better-sqlite3
RUN apk add --no-cache python3 make g++
# ==============================================================================
# Development stage
# ==============================================================================
FROM base AS development
# Copy package files
COPY package*.json ./
COPY server/package*.json ./server/
# Install all dependencies (including devDependencies)
RUN npm install
RUN cd server && npm install
# Copy source code
COPY . .
# Expose ports
EXPOSE 5173 3001
# Development command (override in docker-compose)
CMD ["npm", "run", "dev"]
# ==============================================================================
# Build stage - builds the frontend
# ==============================================================================
FROM base AS builder
# Copy package files
COPY package*.json ./
COPY server/package*.json ./server/
# Install dependencies
RUN npm ci
RUN cd server && npm ci
# Copy source code
COPY . .
# Build frontend
RUN npm run build
# ==============================================================================
# Production stage
# ==============================================================================
FROM node:20-alpine AS production
WORKDIR /app
# Install runtime dependencies for better-sqlite3
RUN apk add --no-cache python3 make g++
# Copy server package files
COPY server/package*.json ./server/
# Install production dependencies only
RUN cd server && npm ci --only=production
# Copy built frontend from builder
COPY --from=builder /app/dist ./dist
# Copy server source
COPY server/src ./server/src
# Create data directory for SQLite
RUN mkdir -p /data
# Set environment
ENV NODE_ENV=production
ENV DATABASE_URL=file:/data/database.db
# Expose port
EXPOSE 3001
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://localhost:3001/api/health || exit 1
# Run production server
WORKDIR /app/server
CMD ["npm", "start"]