Appearance
Docker Build Guide
This monorepo uses a unified Dockerfile that can build any app using Turbo's pruning feature.
Quick Start
Using Docker Compose (Recommended)
bash
# Start sample-app
docker-compose up -d sample-app
# Start all apps
docker-compose up -d
# View logs
docker-compose logs -f sample-app
# Stop all services
docker-compose downUsing Docker Build Directly
bash
# Build with default settings (sample-app, Node 22)
docker build -t sample-app .
# Build a different app
docker build --build-arg APP_NAME=api -t api .
# Custom Node version and start command
docker build \
--build-arg APP_NAME=api \
--build-arg NODE_VERSION=20 \
--build-arg START_COMMAND="node dist/main.js" \
-t api .Using the Helper Script
bash
# Build sample-app with Node 22 (default)
./docker-build.sh sample-app
# Build api with Node 20
./docker-build.sh api 20Build Arguments
APP_NAME(default:sample-app) - The app to build fromapps/directoryNODE_VERSION(default:22) - Node.js version to useSTART_COMMAND(default:"node dist/index.js") - Command to start the app
Adding a New App to Docker Compose
Edit docker-compose.yml and add a new service:
yaml
your-app:
build:
context: .
dockerfile: Dockerfile
args:
APP_NAME: your-app
NODE_VERSION: 22
START_COMMAND: 'node dist/main.js'
image: your-app:latest
container_name: your-app
ports:
- '4000:4000'
environment:
- NODE_ENV=production
restart: unless-stoppedHow It Works
- Prune Stage: Uses
turbo pruneto extract only the dependencies needed for your app - Install Stage: Installs dependencies based on the pruned lockfile
- Build Stage: Copies source code and builds the app using Turbo
- Runner Stage: Creates a minimal Alpine-based production image with only the built artifacts
This approach ensures:
- ✅ Fast builds with layer caching
- ✅ Small production images (only necessary dependencies)
- ✅ Consistent builds across all apps
- ✅ Proper handling of monorepo workspace dependencies