Overview
SkillRise uses a containerized architecture with separate Docker images for the client and server. Both images are built using multi-stage builds for optimal security and performance.Server Image
Node.js 20 Alpine with production dependencies
Client Image
Nginx Alpine serving optimized Vite build
Quick Start with Docker Compose
The fastest way to deploy SkillRise is using the pre-built images from Docker Hub.Create docker-compose.yml
Create a
docker-compose.yml file with the following configuration:docker-compose.yml
Configure Environment Variables
Create a
server/.env file with all required environment variables. See the Environment Variables guide for the complete reference.Start the Containers
- Pull the latest images from Docker Hub
- Start the server on port 3000
- Start the client on port 80
- Automatically restart containers on failure
Server Dockerfile
The server uses a single-stage build optimized for production:server/Dockerfile
Server Image Features
Security Hardening
Security Hardening
- Runs as non-root user (
appuser) - Minimal Alpine Linux base image
- Production dependencies only (
--omit=dev) - Proper file ownership with
--chown
Optimization
Optimization
- Uses
npm cifor reproducible builds - Node.js 20 LTS for stability
- Small image size (~150MB)
Configuration
Configuration
- Exposes port 3000
- Reads environment from
.envfile - Connects to MongoDB on startup
- Initializes Cloudinary connection
Client Dockerfile
The client uses a multi-stage build to separate build dependencies from the runtime:client/Dockerfile
Client Image Features
Multi-Stage Build
Multi-Stage Build
Stage 1 (Builder):
- Installs all dependencies (including devDependencies)
- Receives build-time arguments for Vite configuration
- Compiles React app with Vite
- Produces optimized static files in
/app/dist
- Uses minimal Nginx Alpine image
- Copies only the built static files
- No Node.js or build tools in final image
- Results in ~25MB image size
Nginx Configuration
Nginx Configuration
The client includes a custom This ensures React Router works correctly by serving
nginx.conf for SPA routing:client/nginx.conf
index.html for all routes.Build Arguments
Build Arguments
The client requires three build-time arguments:
VITE_CLERK_PUBLISHABLE_KEY- Clerk authentication public keyVITE_STRIPE_PUBLISHABLE_KEY- Stripe payment public keyVITE_BACKEND_URL- Backend API URL (e.g.,http://localhost:3000)
Building Custom Images
If you need to build images locally or customize the build:Build Server Image
Build Client Image
Docker Compose with Custom Images
To use your custom images:docker-compose.custom.yml
Container Management
View Logs
Restart Services
Stop and Remove
Update to Latest Images
Production Considerations
Reverse Proxy Setup
Reverse Proxy Setup
In production, use a reverse proxy like Nginx or Traefik:
Resource Limits
Resource Limits
Add resource constraints to prevent resource exhaustion:
docker-compose.yml
Health Checks
Health Checks
Add health checks for automatic recovery:
docker-compose.yml
Logging Configuration
Logging Configuration
Configure log rotation to prevent disk space issues:
docker-compose.yml
Network Isolation
Network Isolation
Use custom networks for service isolation:
docker-compose.yml
Troubleshooting
Server Won't Start
Server Won't Start
Check logs:Common issues:
- Missing environment variables (check
server/.env) - MongoDB connection failure (verify
MONGODB_URI) - Port 3000 already in use (change port mapping)
Client Shows Blank Page
Client Shows Blank Page
Check if build arguments were set:Check Nginx logs:
- Verify
VITE_BACKEND_URLpoints to correct server - Check browser console for errors
- Ensure Clerk public key is valid
API Requests Failing
API Requests Failing
Check CORS configuration:Check network connectivity:
- Ensure
FRONTEND_URLin server.envmatches client URL - Verify
VITE_BACKEND_URLin client build matches server URL
Container Keeps Restarting
Container Keeps Restarting
Check restart logs:Common causes:
- Application crash on startup
- Failed dependency initialization (DB, Cloudinary)
- Invalid configuration