-
Notifications
You must be signed in to change notification settings - Fork 0
DOCKER
github-actions[bot] edited this page Feb 21, 2026
·
1 revision
# Using Makefile
make dev-up # Start all services in dev mode
make dev-logs # Follow logs
make dev-down # Stop services
# Or using docker-compose directly
docker compose -f docker-compose.yml up -d --build# 1. Copy and configure production env
cp .env.prod.example .env.prod
# Edit .env.prod with your production values
# 2. Start services
make prod-up
make prod-logs-
Layer Caching Optimization
- Package files copied before source code
- Reduces rebuild time when only code changes
-
Multi-stage Builds (Production)
- Separate build and runtime stages
- Smaller final images (~50% reduction)
- Production dependencies only in final image
-
Package Manager
- Switched from npm to pnpm (faster, better caching)
- Locked versions with
--frozen-lockfile
-
Health Checks
- MongoDB health check added
- Services wait for dependencies to be ready
- Prevents connection errors on startup
-
Security Improvements
- Secrets moved to environment variables
-
.env.prod.exampletemplate provided - No hardcoded credentials in git
-
.dockerignore Files
- Excludes node_modules, logs, IDE files
- Faster builds, smaller contexts
| Metric | Before | After |
|---|---|---|
| Server image size (prod) | ~450MB | ~200MB |
| Build time (code change) | ~2min | ~10sec |
| Startup reliability | β Race conditions | β Health checks |
| Security | β Env-based |
-
.env.example- Template for development -
.env.prod.example- Template for production - Create
.env.prodfrom template before production deployment
# In .env.prod
MONGO_ROOT_PASSWORD=<strong-random-password>
JWT_SECRET=<long-random-string-min-32-chars>
CLIENT_URL=https://your-domain.com
NEXT_PUBLIC_API_URL=https://api.your-domain.com/api# Development
make dev-up # Start dev environment
make dev-down # Stop dev environment
make dev-logs # View logs
make dev-restart # Restart services
# Production
make prod-up # Start prod environment
make prod-down # Stop prod environment
make prod-logs # View logs
make prod-restart # Restart services
# Cleanup
make clean # Remove containers and temp files
make fclean # Remove everything including volumes (β οΈ data loss)MongoDB healthcheck runs every 10s with 5 retries. Services won't start until MongoDB is ready.
-
mongodb_datavolume persists database across restarts - Use
make fcleanto reset (β οΈ deletes all data)
- Dev: Client on
:3002, Server on:5000, MongoDB on:27017 - Prod: Client on
:3000, Server on:5000, MongoDB on:27017
View logs: make dev-logs or docker compose logs -f <service-name>