Docker Deployment Guide
Deploy FSS to production using Docker containers for consistent, reproducible deployments.
Prerequisites
- Docker Engine 20.10+
- Docker Compose V2
- At least 4GB RAM available for containers
- PostgreSQL database (can be hosted separately or use the included database service)
Quick Start with Docker Compose
1. Clone and Navigate
git clone #.git
cd fss/projects/fss
2. Configure Environment
Copy the example environment file and configure your settings:
cp backend/.env.example .env
Edit the .env file with your production values:
# Database
DATABASE_URL=postgresql://user:password@db:5432/fss
REDIS_URL=redis://redis:6379
# JWT
JWT_SECRET=your-super-secret-jwt-key-change-in-production
JWT_EXPIRATION=15m
REFRESH_TOKEN_EXPIRATION=7d
# Email (optional)
SMTP_HOST=smtp.example.com
SMTP_PORT=587
[email protected]
SMTP_PASSWORD=your-email-password
# Domain
FRONTEND_URL=https://yourdomain.com
BACKEND_URL=https://api.yourdomain.com
3. Start Services
docker-compose up -d
This will start:
- PostgreSQL database
- Redis cache
- NestJS backend API
- Next.js frontend
- Nginx reverse proxy (if configured)
Production Deployment
Production Docker Compose
Create a docker-compose.prod.yml file:
version: '3.8'
services:
postgres:
image: postgres:15-alpine
container_name: fss-postgres
restart: unless-stopped
environment:
POSTGRES_USER: fss_user
POSTGRES_PASSWORD: ${DB_PASSWORD}
POSTGRES_DB: fss_db
volumes:
- postgres_data:/var/lib/postgresql/data
networks:
- fss-network
healthcheck:
test: ["CMD-SHELL", "pg_isready -U fss_user -d fss_db"]
interval: 10s
timeout: 5s
retries: 5
redis:
image: redis:7-alpine
container_name: fss-redis
restart: unless-stopped
command: redis-server --appendonly yes
volumes:
- redis_data:/data
networks:
- fss-network
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 5s
retries: 5
backend:
image: bwebsolutions/fss-backend:latest
container_name: fss-backend
restart: unless-stopped
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
environment:
DATABASE_URL: postgresql://fss_user:${DB_PASSWORD}@postgres:5432/fss_db
REDIS_URL: redis://redis:6379
JWT_SECRET: ${JWT_SECRET}
JWT_EXPIRATION: 15m
REFRESH_TOKEN_EXPIRATION: 7d
FRONTEND_URL: ${FRONTEND_URL}
BACKEND_URL: ${BACKEND_URL}
NODE_ENV: production
networks:
- fss-network
ports:
- "3001:3001"
volumes:
- uploads_data:/app/uploads
frontend:
image: bwebsolutions/fss-frontend:latest
container_name: fss-frontend
restart: unless-stopped
depends_on:
- backend
environment:
NEXT_PUBLIC_API_URL: ${BACKEND_URL}
NODE_ENV: production
networks:
- fss-network
ports:
- "3000:3000"
volumes:
postgres_data:
redis_data:
uploads_data:
networks:
fss-network:
driver: bridge
Build Images
# Build backend image
docker build -t bwebsolutions/fss-backend:latest ./backend
# Build frontend image
docker build -t bwebsolutions/fss-frontend:latest ./frontend
# Or build multi-platform
docker buildx build --platform linux/amd64,linux/arm64 \
-t bwebsolutions/fss-backend:latest ./backend \
--push
Environment Variables
Required Variables
| Variable | Description | Example |
|---|---|---|
DATABASE_URL | PostgreSQL connection string | postgresql://user:pass@host:5432/db |
REDIS_URL | Redis connection string | redis://redis:6379 |
JWT_SECRET | Secret key for JWT signing | (generate secure random string) |
JWT_EXPIRATION | Access token lifetime | 15m, 1h |
REFRESH_TOKEN_EXPIRATION | Refresh token lifetime | 7d, 30d |
Optional Variables
| Variable | Description | Default |
|---|---|---|
PORT | Backend port | 3001 |
NODE_ENV | Environment mode | development |
FRONTEND_URL | Frontend URL for CORS | http://localhost:3000 |
BACKEND_URL | Backend URL for generating links | http://localhost:3001 |
SMTP_HOST | SMTP server for emails | - |
SMTP_PORT | SMTP port | 587 |
SMTP_USER | SMTP username | - |
SMTP_PASSWORD | SMTP password | - |
Docker Hub Images
Pre-built images are available on Docker Hub:
# Backend
docker pull bwebsolutions/fss-backend:latest
# Frontend
docker pull bwebsolutions/fss-frontend:latest
Health Checks
All containers include health checks. Monitor with:
docker-compose ps
docker-compose logs -f
Updating Deployment
# Pull latest images
docker-compose pull
# Restart services
docker-compose up -d
# Or for zero-downtime updates
docker-compose up -d --no-deps backend frontend
Troubleshooting
Database Connection Issues
# Check database health
docker-compose exec postgres pg_isready -U fss_user
# View database logs
docker-compose logs postgres
Backend Connection Issues
# Check backend logs
docker-compose logs backend
# Test backend health
curl http://localhost:3001/health
Reset Everything
docker-compose down -v
docker-compose up -d
Next Steps
- Environment Variables - Configure your deployment
- Security Best Practices - Production security
- Monitoring Guide - Setup monitoring and logging