Overview
Trazea includes Docker configuration for both development and production deployments. The multi-stage Dockerfile optimizes for fast development with hot-reload and efficient production builds with Nginx.Prerequisites
- Docker installed (version 20.10+)
- Docker Compose installed (version 2.0+)
.envfile with required environment variables
Quick Start
Development Mode
Run Trazea in development mode with hot-reload:http://localhost:5173
Production Mode
Build and run the production container:http://localhost
Dockerfile Architecture
Trazea uses a multi-stage Dockerfile with three stages:Stage 1: Development Base (dev)
- Uses Node 22 Alpine for minimal image size
- Enables pnpm via corepack
- Installs all dependencies (including devDependencies)
Stage 2: Builder (builder)
- Accepts build-time arguments for Supabase configuration
- Runs
pnpm buildwith environment variables - Outputs optimized static files to
/app/dist
Environment variables are baked into the build at compile time. To change them, you must rebuild the image.
Stage 3: Production Runner (runner)
- Uses Nginx Alpine for minimal runtime image (~25 MB)
- Copies only production files from builder stage
- Exposes port 80 for HTTP traffic
- Runs Nginx in foreground mode
Docker Compose Configuration
Thedocker-compose.yml file is optimized for local development:
docker-compose.yml
Key Features
Hot Module Replacement (HMR)
Hot Module Replacement (HMR)
Source code is mounted as a volume (
.:/app), so changes are instantly reflected without rebuilding.The VITE_WATCH_USE_POLLING=true environment variable enables file watching on Windows and macOS hosts.Node Modules Protection
Node Modules Protection
The
/app/node_modules volume ensures that the container’s installed dependencies aren’t overwritten by the host’s node_modules folder.Environment Variables
Environment Variables
The
env_file: - .env directive loads all variables from your .env file into the container.Deployment Scenarios
Local Development
http://localhost:5173
Production Deployment
Docker Swarm / Kubernetes
For orchestrated deployments, use the production image with config management:Environment Variables in Docker
Build-Time Variables
Passed as--build-arg during docker build:
Runtime Variables (Development Only)
In development mode withdocker-compose, variables are loaded from .env:
Nginx Configuration
The production image uses the default Nginx Alpine configuration, which automatically:- Serves files from
/usr/share/nginx/html - Handles SPA routing with proper fallback to
index.html - Compresses assets with gzip
- Sets cache headers for static files
nginx.conf:
nginx.conf
Troubleshooting
Port Already in Use
Port Already in Use
If port 5173 or 80 is already in use:Or stop the conflicting container:
Changes Not Reflecting (Development)
Changes Not Reflecting (Development)
- Ensure volume is mounted:
-v .:/app - Check file watching is enabled:
VITE_WATCH_USE_POLLING=true - Restart the container:
docker-compose restart
Build Failures
Build Failures
Check build logs:Common issues:
- Missing build args: Add
--build-arg PUBLIC_SUPABASE_URL=... - TypeScript errors: Run
pnpm buildlocally first to identify issues - Out of memory: Increase Docker memory limit in settings
Container Immediately Exits
Container Immediately Exits
Check container logs:For production containers, ensure Nginx is running:
Image Size Optimization
The multi-stage build keeps images small:| Stage | Size | Contents |
|---|---|---|
| dev | ~800 MB | Node + source + all dependencies |
| builder | ~850 MB | dev + built files |
| runner | ~25 MB | Nginx + built static files only |
Production Checklist
Build Arguments
✓ Production Supabase URL and key configured as build args✓ Sentry DSN included in build (if used)
Image Security
✓ No secrets in build logs or layers✓ Base images up to date (
node:22-alpine, nginx:alpine)✓ Image scanned for vulnerabilitiesDeployment
✓ Container runs with
--restart unless-stopped✓ Health checks configured (optional)✓ SSL/TLS termination at load balancer or reverse proxyNext Steps
Environment Setup
Configure environment variables and application settings
Supabase Configuration
Set up authentication, RLS policies, and CORS