Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -168,3 +168,10 @@ WORLDMONITOR_VALID_KEYS=
# Convex deployment URL for email registration storage.
# Set up at: https://dashboard.convex.dev/
CONVEX_URL=

# ------ DOCKER SELF-HOSTING ------

# Only needed when using docker-compose
# Leave as default when using docker-compose
REDIS_URL=redis://redis:6379
PORT=3001
39 changes: 39 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# ─────────────────────────────────────────
# Stage 1: Build the Vite application
# ─────────────────────────────────────────
FROM node:20-alpine AS builder

WORKDIR /app

# Install dependencies using npm ci for reproducible builds
COPY package*.json ./
RUN npm ci

# Copy source code and build
COPY . .
RUN npm run build

# ─────────────────────────────────────────
# Stage 2: Serve with Nginx
# ─────────────────────────────────────────
FROM nginx:alpine

# Copy custom nginx configuration
COPY nginx.conf /etc/nginx/conf.d/default.conf

# Copy built files from builder stage
COPY --from=builder /app/dist /usr/share/nginx/html

# Create cache directories
RUN mkdir -p /var/cache/nginx/client_temp \
/var/cache/nginx/proxy_temp \
/var/cache/nginx/fastcgi_temp \
/var/cache/nginx/uwsgi_temp \
/var/cache/nginx/scgi_temp \
&& chown -R nginx:nginx /var/cache/nginx

# Expose port 80
EXPOSE 80

# Start nginx
CMD ["nginx", "-g", "daemon off;"]
53 changes: 53 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
version: '3.8'

services:
# Frontend - Vite SPA served via Nginx
app:
build:
context: .
dockerfile: Dockerfile
ports:
- "3000:80"
depends_on:
- api
restart: unless-stopped
networks:
- worldmonitor

# Backend - Express API replacing Vercel Edge Functions
api:
build:
context: ./server
dockerfile: Dockerfile
ports:
- "3001:3001"
env_file:
- .env
depends_on:
- redis
restart: unless-stopped
environment:
- REDIS_URL=redis://redis:6379
- PORT=3001
networks:
- worldmonitor

# Redis - caching layer
redis:
image: redis:7-alpine
ports:
- "6379:6379"
volumes:
- redis_data:/data
restart: unless-stopped
networks:
- worldmonitor
command: redis-server --appendonly yes

volumes:
redis_data:
driver: local

networks:
worldmonitor:
driver: bridge
16 changes: 16 additions & 0 deletions docker/server/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM node:20-alpine

WORKDIR /app

# Copy package files
COPY package*.json ./

# Install dependencies
RUN npm ci --only=production

# Copy server source
COPY . .

EXPOSE 3001

CMD ["node", "index.js"]
Loading