Overview
SkillRise includes Docker configurations for both development and production deployments. Docker provides a consistent, isolated environment that works across all platforms.Benefits of Docker:
- No need to install Node.js, MongoDB, or other dependencies locally
- Consistent environment across development and production
- Easy scaling and deployment
- Pre-configured networking between services
Prerequisites
Docker
Docker Engine 20.x or higher
Docker Compose
v2.x (included with Docker Desktop)
Install Docker
- macOS
- Linux
- Windows
Option 1: Docker Desktop (Recommended)Option 2: Homebrew
- Download Docker Desktop for Mac
- Install the
.dmgfile - Open Docker Desktop and follow the setup wizard
- Verify installation:
Project Docker Structure
SkillRise includes the following Docker configuration files:Dockerfile Overview
Backend Dockerfile
The server uses a simple Node.js Alpine image for a lightweight container.server/Dockerfile
Key features
Key features
- Alpine Linux - Minimal base image (~5 MB vs 1+ GB for full Ubuntu)
- Non-root user - Security best practice (runs as
appuserinstead ofroot) - Production dependencies only -
npm ci --omit=devskips devDependencies - Layer caching -
package.jsoncopied before source code for faster rebuilds
Frontend Dockerfile
The client uses a multi-stage build to keep the final image small.client/Dockerfile
Key features
Key features
- Multi-stage build - Build stage is discarded, final image only contains static files + nginx
- Build arguments - Environment variables are baked into the build at compile time
- Nginx for serving - Efficient static file server with SPA fallback routing
- Tiny image size - Final image is ~50 MB (vs ~1 GB if we kept Node.js)
Nginx Configuration
client/nginx.conf
The
try_files directive ensures that React Router routes (e.g., /courses/123) serve index.html instead of returning 404.Docker Compose Configuration
Thedocker-compose.yml file orchestrates both services:
docker-compose.yml
string
Pre-built Docker Hub image for the backend. You can replace this with
build: ./server to build locally.array
Maps host port 3000 to container port 3000 (Express server).
string
Loads environment variables from
server/.env into the container.array
Ensures the server starts before the client container.
Running with Docker Compose
Using Pre-built Images (Quickest)
The easiest way is to use pre-built images from Docker Hub:1
Create environment files
Ensure both
server/.env and client/.env are configured. See Configuration.2
Start services
Expected output
Expected output
The
-d flag runs in detached mode (background):3
Access the application
- Frontend: http://localhost
- Backend API: http://localhost:3000
4
Stop services
Building Locally
To build images from source instead of using Docker Hub:1
Modify docker-compose.yml
Replace image references with build contexts:
docker-compose.yml
2
Create root .env file
For client build args, create a
.env in the project root:.env
3
Build and run
Build output
Build output
Docker Commands Reference
Seeding Data in Docker
To populate the database with demo data:Expected output
Expected output
Environment Variables in Docker
Backend
Environment variables are loaded fromserver/.env via the env_file directive:
server/.env are automatically available in the container.
Frontend (Build Arguments)
For the client, environment variables must be passed as build arguments because Vite bundles them at build time:.env file (not client/.env).
Production Deployment
For production, use the pre-built images with a Docker registry:Building and Pushing Images
1
Build production images
2
Push to registry
3
Update docker-compose.yml on server
4
Deploy
The official SkillRise images are available at:
pushkarverma/skillrise-server:latestpushkarverma/skillrise-client:latest
Docker vs Local Development
Recommendation: Use local development for day-to-day coding (faster hot reload). Use Docker for testing full-stack integration and deployment.
Troubleshooting
Port already in use
Port already in use
Error:
Bind for 0.0.0.0:3000 failed: port is already allocatedSolutions:- Stop the process using the port:
- Or change the port in
docker-compose.yml:
Build fails with npm install errors
Build fails with npm install errors
Error:
npm ERR! network or npm ERR! code ENOTFOUNDSolutions:- Check your internet connection
- Clear Docker build cache:
- Use a different npm registry:
Environment variables not loading
Environment variables not loading
Symptom: App canβt connect to database or external APIsSolutions:
- Verify
server/.envexists and has correct values - Restart containers:
- For client env vars, ensure theyβre in root
.envand rebuild:
Client shows blank page or 404
Client shows blank page or 404
Symptom: Frontend loads but shows white screen or errorsSolutions:
- Check browser console for errors (F12 β Console)
- Verify
VITE_BACKEND_URLmatches the server URL: - Rebuild client image:
- Check nginx logs:
Database connection failed in container
Database connection failed in container
Error:
MongoServerError: connect ECONNREFUSEDSolutions:- If using local MongoDB, change
MONGODB_URIto use host network: - Or add MongoDB as a service in
docker-compose.yml:
Seed script fails inside container
Seed script fails inside container
Error:
MongoServerError: bad authSolutions:- Ensure server container is running:
- Verify
MONGODB_URIinserver/.envis correct - Check server logs:
Next Steps
Seeding Data
Populate database with demo data
CI/CD Pipeline
Automate builds with GitHub Actions
Production Deploy
Deploy to cloud providers