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
Pre-built Docker Hub image for the backend. You can replace this with
build: ./server to build locally.Maps host port 3000 to container port 3000 (Express server).
Loads environment variables from
server/.env into the container.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:Create environment files
Ensure both
server/.env and client/.env are configured. See Configuration.Access the application
- Frontend: http://localhost
- Backend API: http://localhost:3000
Building Locally
To build images from source instead of using Docker Hub: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
The official SkillRise images are available at:
pushkarverma/skillrise-server:latestpushkarverma/skillrise-client:latest
Docker vs Local Development
| Feature | Local Development | Docker |
|---|---|---|
| Setup Time | 15-30 minutes | 5 minutes |
| Dependencies | Node.js, MongoDB, npm | Docker only |
| Hot Reload | ✅ Built-in (Vite, nodemon) | ❌ Requires volume mounts |
| Environment Parity | May differ | ✅ Identical to production |
| Resource Usage | Low | Medium (containers overhead) |
| Debugging | ✅ Easy (direct access) | ⚠️ Requires docker exec |
| Best For | Active development | Testing, CI/CD, production |
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: