Docker
UniPulse uses Docker Compose for both development (database services only) and production (full stack deployment).
Development Setup
docker-compose.yml provides the two infrastructure services needed for local development:
# docker-compose.yml
services:
postgres:
image: postgres:16-alpine
ports:
- "5432:5432"
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: unipulse
volumes:
- postgres_data:/var/lib/postgresql/data
redis:
image: redis:7-alpine
ports:
- "6379:6379"
volumes:
- redis_data:/data
volumes:
postgres_data:
redis_data:
| Service | Image | Port | Purpose |
|---|---|---|---|
| PostgreSQL | postgres:16-alpine | 5432 | Primary database (69+ Prisma models) |
| Redis | redis:7-alpine | 6379 | BullMQ queues, rate limiting, caching |
Commands
# Start services
docker compose up -d
# Check status
docker compose ps
# View logs
docker compose logs -f postgres
docker compose logs -f redis
# Stop services
docker compose down
# Stop and remove data volumes (full reset)
docker compose down -v
Production Setup
docker-compose.prod.yml deploys the full application stack:
# docker-compose.prod.yml (simplified)
services:
postgres:
image: postgres:16-alpine
volumes:
- postgres_data:/var/lib/postgresql/data
restart: always
redis:
image: redis:7-alpine
volumes:
- redis_data:/data
restart: always
api:
build:
context: .
dockerfile: apps/api/Dockerfile
depends_on:
- postgres
- redis
environment:
- DATABASE_URL=postgresql://postgres:${DB_PASSWORD}@postgres:5432/unipulse
- REDIS_URL=redis://redis:6379
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:3000/api/v1/health"]
interval: 30s
timeout: 10s
retries: 3
restart: always
web:
build:
context: .
dockerfile: apps/web/Dockerfile
depends_on:
- api
restart: always
# Served via Nginx (Vite build output as static files)
certbot:
image: certbot/certbot
volumes:
- certbot_conf:/etc/letsencrypt
- certbot_www:/var/www/certbot
# SSL certificate management
Production Services
| Service | Image | Health Check | Purpose |
|---|---|---|---|
postgres | postgres:16-alpine | TCP port 5432 | Primary database |
redis | redis:7-alpine | TCP port 6379 | Queues and caching |
api | Custom Dockerfile | GET /api/v1/health | Express API + BullMQ workers |
web | Custom Dockerfile (Nginx + Vite build) | HTTP 200 | Static frontend files via Nginx |
certbot | certbot/certbot | - | SSL certificate generation and renewal |
Production Commands
# Build and start
docker compose -f docker-compose.prod.yml up -d --build
# Run database migrations
docker compose -f docker-compose.prod.yml exec api npx prisma migrate deploy
# View logs
docker compose -f docker-compose.prod.yml logs -f api
# Restart a single service
docker compose -f docker-compose.prod.yml restart api
# Scale workers (if separated)
docker compose -f docker-compose.prod.yml up -d --scale worker=3
API Dockerfile
# apps/api/Dockerfile
FROM node:20-alpine AS builder
WORKDIR /app
COPY package*.json ./
COPY packages/shared/package.json packages/shared/
COPY apps/api/package.json apps/api/
RUN npm ci
COPY . .
RUN npm run build --filter=shared
RUN npm run build --filter=api
FROM node:20-alpine
WORKDIR /app
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/apps/api/dist ./dist
COPY --from=builder /app/apps/api/prisma ./prisma
COPY --from=builder /app/apps/api/package.json ./
EXPOSE 3000
CMD ["node", "dist/index.js"]
Web Dockerfile
# apps/web/Dockerfile
FROM node:20-alpine AS builder
WORKDIR /app
COPY package*.json ./
COPY packages/shared/package.json packages/shared/
COPY apps/web/package.json apps/web/
RUN npm ci
COPY . .
RUN npm run build --filter=shared
RUN npm run build --filter=web
FROM nginx:alpine
COPY --from=builder /app/apps/web/dist /usr/share/nginx/html
COPY apps/web/nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
Docker Network
All production containers run on the same Docker network, communicating via service names:
Cross-Reference
- Backend Local Setup -- using Docker for development
- Deployment -- full production deployment guide
- Nginx -- reverse proxy configuration
- Environment Variables -- Docker env var configuration
- Control Center Docker Management -- managing containers via UI