-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
74 lines (52 loc) · 1.8 KB
/
Dockerfile
File metadata and controls
74 lines (52 loc) · 1.8 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
# Multi-stage build for minimal image size
# Stage 1: Build frontend
FROM node:20-alpine AS frontend-builder
WORKDIR /app/client
# Copy frontend package files
COPY client/package*.json ./
# Install ALL frontend dependencies (including dev, needed for build)
RUN npm install
# Copy frontend source
COPY client/ ./
# Build frontend
RUN npm run build
# Stage 2: Build backend dependencies
FROM node:20-alpine AS backend-builder
WORKDIR /app
# Copy backend package files
COPY package*.json ./
# Install backend dependencies
RUN npm install --omit=dev
# Stage 3: Final production image
FROM node:20-alpine
# Install bzip2 for MTGJSON decompression
RUN apk add --no-cache bzip2
WORKDIR /app
# Copy backend dependencies from builder
COPY --from=backend-builder /app/node_modules ./node_modules
# Copy backend source
COPY src ./src
COPY scripts ./scripts
COPY package*.json ./
# Copy built frontend from frontend-builder
COPY --from=frontend-builder /app/client/dist ./client/dist
# Copy favicon assets
COPY assets/favicon.ico ./client/dist/favicon.ico
COPY assets/favicon-16x16.png ./client/dist/favicon-16x16.png
COPY assets/favicon-32x32.png ./client/dist/favicon-32x32.png
COPY assets/apple-touch-icon.png ./client/dist/apple-touch-icon.png
COPY assets/android-chrome-192x192.png ./client/dist/android-chrome-192x192.png
COPY assets/android-chrome-512x512.png ./client/dist/android-chrome-512x512.png
# Create data directory
RUN mkdir -p /app/data
# Set environment variables
ENV NODE_ENV=production
ENV PORT=3000
ENV DATABASE_PATH=/app/data/deck-lotus.db
# Expose port
EXPOSE 3000
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=40s \
CMD node -e "require('http').get('http://localhost:3000/health', (r) => {process.exit(r.statusCode === 200 ? 0 : 1)})"
# Start server
CMD ["node", "src/server.js"]