A full-stack application with Node.js/Express backend and Next.js frontend, containerized with Docker.
# Build and start all services
docker-compose up --build
# Run in background
docker-compose up -d --build# Start development environment with hot reloading
docker-compose -f docker-compose.dev.yml up --build
# Run in background
docker-compose -f docker-compose.dev.yml up -d --build# Start development with ngrok tunnels
docker-compose -f docker-compose.dev.yml --profile tunnel up --build
# Start production with ngrok tunnels
docker-compose --profile tunnel up --buildDeepDSA/
βββ backend/ # Node.js/Express API
β βββ Dockerfile # Production backend image
β βββ Dockerfile.dev # Development backend image
β βββ src/ # TypeScript source code
βββ main-fb/ # Next.js frontend
β βββ Dockerfile # Production frontend image
β βββ Dockerfile.dev # Development frontend image
β βββ src/ # React/Next.js source code
βββ docker-compose.yml # Production orchestration
βββ docker-compose.dev.yml # Development orchestration
βββ README.md # This file
| Service | Port | Description |
|---|---|---|
| Frontend | 3000 | Next.js application |
| Backend | 5373 | Express.js API |
| MongoDB | 27017 | Database |
| Redis | 6379 | Cache & sessions |
| Mongo Express | 8081 | Database management UI |
| Ngrok | 4040 | All tunnels web interface |
MONGO_URI=mongodb://mongo:27017/deepdsa
PORT=5373
NODE_ENV=development
FRONTEND_URL=http://localhost:3000NEXT_PUBLIC_API_URL=http://localhost:5373# Get your auth token from https://dashboard.ngrok.com/get-started/your-authtoken
NGROK_AUTHTOKEN=your_ngrok_auth_token_hereThe development setup uses Docker Compose's watch functionality for optimal development experience:
- Source Code:
./backend/srcβ/app/src(sync) - Package Files:
./backend/package.jsonβ rebuild container - Dependencies:
./backend/package-lock.jsonβ sync - Ignored:
node_modules/,dist/,logs/
- Source Code:
./main-fb/srcβ/app/src(sync) - Public Assets:
./main-fb/publicβ/app/public(sync) - Config Files:
next.config.ts,tsconfig.json,postcss.config.mjsβ sync - Package Files:
./main-fb/package.jsonβ rebuild container - Ignored:
node_modules/,.next/
sync: File changes are immediately synced to the containerrebuild: Container is rebuilt when package.json changes
Access MongoDB Express at http://localhost:8081:
- Username:
admin - Password:
admin123
# Start development with watch functionality
docker-compose -f docker-compose.dev.yml up --build
# View logs
docker-compose logs -f [service-name]
# Execute commands in containers
docker-compose exec backend npm run build
docker-compose exec frontend npm run lint
# Stop all services
docker-compose down
# Remove volumes (β οΈ deletes data)
docker-compose down -v
# Rebuild specific service
docker-compose build backend
# Scale services
docker-compose up --scale backend=2
# Watch specific files/directories
# The watch functionality automatically monitors:
# - Source code changes (immediate sync)
# - Package.json changes (container rebuild)
# - Configuration file changes (sync)- Port conflicts: Ensure ports 3000, 5000, 27017, 6379, 8081 are available
- Permission errors: Run
sudo chown -R $USER:$USER .in project directory - Build failures: Clear Docker cache with
docker system prune -a
- Backend:
http://localhost:5373/ - Frontend:
http://localhost:3000/ - MongoDB:
docker-compose exec mongo mongosh - Redis:
docker-compose exec redis redis-cli ping
# Build optimized images
docker-compose build
# Start production services
docker-compose up -d- Create
.env.localfiles in bothbackend/andmain-fb/ - Set production environment variables
- Update
FRONTEND_URLandNEXT_PUBLIC_API_URLfor your domain
# All services
docker-compose logs
# Specific service
docker-compose logs backend
# Follow logs
docker-compose logs -f frontend# Container stats
docker stats
# Disk usage
docker system df- Non-root users in containers
- Isolated network (
deepdsa-network) - Persistent volumes for data
- Health checks for all services
-
Get Ngrok Auth Token:
- Sign up at ngrok.com
- Get your auth token from dashboard.ngrok.com
-
Set Environment Variable:
export NGROK_AUTHTOKEN=your_ngrok_auth_token_here -
Start with Tunnels:
# Development with tunnels docker-compose -f docker-compose.dev.yml --profile tunnel up --build # Production with tunnels docker-compose --profile tunnel up --build
- All Tunnels: Visit
http://localhost:4040for all tunnel status - Public URLs: The ngrok web interface will show all your public URLs
Once running, you'll get public URLs like:
- Backend:
https://abc123.ngrok.ioβ Your API - Frontend:
https://xyz789.ngrok.ioβ Your Next.js app - MongoDB:
tcp://def456.ngrok.io:12345β Your database (TCP tunnel)
- Automatic HTTPS: All tunnels are HTTPS by default
- Custom Domains: Available with paid ngrok plans
- Request Inspection: View all requests in the ngrok web interface
- Webhook Testing: Perfect for testing webhooks and integrations
- Public Access: Anyone with the ngrok URL can access your app
- Development Only: Use tunnels only for development/testing
- Auth Token: Keep your ngrok auth token secure
- Rate Limits: Free ngrok accounts have rate limits
- Development volumes preserve
node_modulesfor faster builds - MongoDB data persists in
mongo_datavolume - Redis data persists in
redis_datavolume - Frontend uses Next.js standalone output for production
- Ngrok tunnels provide public HTTPS URLs for local development