Deployment Guide
Recommended Deployment
For production deployment, we recommend using Coolify with pre-built Docker images. See the Coolify Deployment Guide for a complete setup guide.
The options below are alternative deployment methods for reference.
Overview
This guide covers deploying the CS2Inspect application to production environments. The application is a Nuxt 4 server-side rendered (SSR) application with a backend API and requires a MariaDB database and optionally a Steam bot account.
Deployment Options
1. Vercel (Alternative)
Vercel provides seamless Nuxt 4 deployment with automatic builds, serverless functions, and edge caching.
Prerequisites
- Vercel account
- External MariaDB database (e.g., PlanetScale, AWS RDS, DigitalOcean)
- GitHub repository connected to Vercel
Setup Steps
Connect Repository to Vercel:
- Go to Vercel Dashboard
- Click "New Project"
- Import your GitHub repository
- Select the repository:
sak0a/cs2inspect-web
Configure Build Settings:
Framework Preset: Nuxt.js Build Command: bun run build Output Directory: .output/public Install Command: bun install Note: npm is also supported if Bun is not availableSet Environment Variables:
Complete Environment Variables
For a complete list of all environment variables and their descriptions, see the Setup Guide - Environment Configuration.
In Vercel project settings → Environment Variables, add the required variables:
# Server Configuration PORT=3210 HOST=0.0.0.0 # JWT Configuration JWT_TOKEN=<your-secure-random-key-32-chars> JWT_EXPIRY=7d # Database Configuration DATABASE_HOST=<your-db-host> DATABASE_PORT=3306 DATABASE_USER=<your-db-user> DATABASE_PASSWORD=<your-db-password> DATABASE_NAME=csinspect DATABASE_CONNECTION_LIMIT=10 # Steam API STEAM_API_KEY=<your-steam-api-key> # Optional: Steam Bot Account STEAM_USERNAME=<bot-username> STEAM_PASSWORD=<bot-password> # Logging LOG_API_REQUESTS=trueDeploy:
- Click "Deploy"
- Vercel will build and deploy your application
- Access via provided URL:
https://your-project.vercel.app
Custom Domain (Optional):
- Go to Project Settings → Domains
- Add your custom domain
- Update DNS records as instructed
Vercel Configuration File
Create vercel.json in the project root:
{
"version": 2,
"builds": [
{
"src": "nuxt.config.ts",
"use": "@nuxtjs/vercel-builder"
}
],
"routes": [
{
"src": "/api/(.*)",
"dest": "/api/$1"
},
{
"src": "/(.*)",
"dest": "/"
}
]
}2. Docker Deployment
Deploy using Docker containers for full control and portability.
Prerequisites
- Docker and Docker Compose installed
- Server with Docker support (VPS, dedicated server)
- Domain name pointed to server IP
Setup Steps
Build Docker Image:
bashdocker build -t cs2inspect-web .Docker Compose Setup:
Create
docker-compose.coolify.yml:yamlversion: '3.8' services: app: image: cs2inspect-web container_name: cs2inspect-app restart: unless-stopped ports: - "3210:3210" environment: - PORT=3210 - HOST=0.0.0.0 - DATABASE_HOST=database - DATABASE_PORT=3306 - DATABASE_USER=csinspect - DATABASE_PASSWORD=${DATABASE_PASSWORD} - DATABASE_NAME=csinspect - JWT_TOKEN=${JWT_TOKEN} - STEAM_API_KEY=${STEAM_API_KEY} - STEAM_USERNAME=${STEAM_USERNAME} - STEAM_PASSWORD=${STEAM_PASSWORD} depends_on: - db healthcheck: test: ["CMD", "curl", "-f", "http://localhost:3210/api/health/ready"] interval: 30s timeout: 5s retries: 3 start_period: 30s networks: - cs2inspect-network db: image: mariadb:11 container_name: cs2inspect-db restart: unless-stopped environment: - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD} - MYSQL_DATABASE=csinspect - MYSQL_USER=csinspect - MYSQL_PASSWORD=${DATABASE_PASSWORD} volumes: - db-data:/var/lib/mysql - ./db_structure.sql:/docker-entrypoint-initdb.d/init.sql ports: - "3306:3306" networks: - cs2inspect-network nginx: image: nginx:alpine container_name: cs2inspect-nginx restart: unless-stopped ports: - "80:80" - "443:443" volumes: - ./nginx.conf:/etc/nginx/nginx.conf - ./ssl:/etc/nginx/ssl depends_on: - app networks: - cs2inspect-network volumes: db-data: networks: cs2inspect-network: driver: bridgeNginx Configuration:
Create
nginx.conf:nginxevents { worker_connections 1024; } http { upstream app { server app:3210; } server { listen 80; server_name your-domain.com; # Redirect HTTP to HTTPS return 301 https://$server_name$request_uri; } server { listen 443 ssl http2; server_name your-domain.com; ssl_certificate /etc/nginx/ssl/cert.pem; ssl_certificate_key /etc/nginx/ssl/key.pem; location / { proxy_pass http://app; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection 'upgrade'; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_cache_bypass $http_upgrade; } } }Deploy:
bash# Create .env file with secrets cp .env.example .env # Edit .env with production values # Start services docker-compose -f docker-compose.coolify.yml up -d # View logs docker-compose -f docker-compose.coolify.yml logs -fSSL Certificate (Let's Encrypt):
bash# Install certbot sudo apt-get install certbot # Generate certificate sudo certbot certonly --standalone -d your-domain.com # Copy certificates sudo cp /etc/letsencrypt/live/your-domain.com/fullchain.pem ./ssl/cert.pem sudo cp /etc/letsencrypt/live/your-domain.com/privkey.pem ./ssl/key.pem
3. Node.js + PM2
Deploy directly to a VPS using Node.js and PM2 process manager.
Prerequisites
- VPS with Node.js 20+ installed
- PM2 installed globally:
npm install -g pm2(orbun install -g pm2) - Nginx for reverse proxy
- MariaDB database
Setup Steps
Development Setup
For detailed installation and setup instructions, see the Setup Guide. The steps below focus on production-specific deployment.
Clone Repository:
bashcd /var/www git clone https://github.com/sak0a/cs2inspect-web.git cd cs2inspect-webInstall Dependencies:
See Setup Guide - Install Dependencies for details.
bash# Using Bun (recommended) bun install # Or using npm npm installBuild Application:
bash# Using Bun bun run build # Or using npm npm run buildConfigure Environment:
See Setup Guide - Environment Configuration for complete environment variable documentation.
bashcp .env.example .env nano .env # Set production values (see setup.md for all required variables)PM2 Configuration:
Create
ecosystem.config.js:javascriptmodule.exports = { apps: [{ name: 'cs2inspect', script: './.output/server/index.mjs', instances: 'max', exec_mode: 'cluster', env: { NODE_ENV: 'production', PORT: 3210, HOST: '127.0.0.1' }, error_file: './logs/error.log', out_file: './logs/out.log', log_date_format: 'YYYY-MM-DD HH:mm:ss Z', merge_logs: true, max_memory_restart: '1G' }] }Start with PM2:
bash# Start application pm2 start ecosystem.config.js # Save PM2 configuration pm2 save # Setup startup script pm2 startup # Run the command it outputsNginx Configuration:
nginxserver { listen 80; server_name your-domain.com; location / { proxy_pass http://127.0.0.1:3210; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection 'upgrade'; proxy_set_header Host $host; proxy_cache_bypass $http_upgrade; } }Enable and Restart Nginx:
bashsudo ln -s /etc/nginx/sites-available/cs2inspect /etc/nginx/sites-enabled/ sudo nginx -t sudo systemctl restart nginx
4. Other Platforms
CS2Inspect is built with Nuxt 4, which can be deployed to many different platforms. For detailed deployment options beyond the ones listed above, please refer to the official Nuxt deployment documentation:
Nuxt 4 Deployment Documentation
The Nuxt docs provide comprehensive guides for deploying to platforms including:
- Cloudflare Pages
- Netlify
- AWS (Amplify, Lambda, EC2)
- Azure Static Web Apps
- Digital Ocean App Platform
- Heroku
- Railway
- Render
- And many more...
Each platform may have specific requirements and configuration. Consult the Nuxt documentation for platform-specific setup instructions.
Database Deployment
Option 1: Managed Database (Recommended)
Use a managed database service for reliability and automatic backups:
- PlanetScale: MySQL-compatible, serverless, free tier available
- AWS RDS: Managed MariaDB/MySQL
- DigitalOcean Managed Databases: Simple setup, automatic backups
- Google Cloud SQL: Highly available MySQL
Setup Example (PlanetScale):
- Create account at planetscale.com
- Create new database
- Create branch (e.g.,
production) - Get connection string
- Add to environment variables
Option 2: Self-Hosted Database
Database Setup
For detailed database setup instructions including Docker and local MariaDB installation, see the Setup Guide - Database Setup.
Run MariaDB on your own server:
# Install MariaDB
sudo apt-get install mariadb-server
# Secure installation
sudo mysql_secure_installation
# Create database
sudo mysql -u root -pCREATE DATABASE csinspect CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'csinspect'@'%' IDENTIFIED BY 'strong_password';
GRANT ALL PRIVILEGES ON csinspect.* TO 'csinspect'@'%';
FLUSH PRIVILEGES;
EXIT;Automatic Migrations
The application uses automatic database migrations. You don't need to manually import the schema - migrations run automatically on server startup. See Setup Guide - Database Management for details.
CI/CD Pipeline
GitHub Actions
The project uses GitHub Actions for CI/CD:
# The project uses 4 CI/CD workflows:
# - ci.yml: Tests, lints, and builds on push to master/dev
# - docker.yml: Builds Docker images on push to master/dev and tag pushes
# - release.yml: Creates releases and triggers Docker builds
# - deploy-docs.yml: Builds and deploys VitePress docs to GitHub Pages
# See the GitHub Actions documentation for details.Manual Deployment Script
Create scripts/deploy.sh:
#!/bin/bash
echo "🚀 Starting deployment..."
# Pull latest code
git pull origin master
# Install dependencies (using Bun)
bun install
# Or using npm
npm ci
# Build application
bun run build
# or
npm run build
# Restart PM2
pm2 restart cs2inspect
# Check status
pm2 status
echo "✅ Deployment complete!"Make it executable:
chmod +x scripts/deploy.shEnvironment-Specific Configuration
Development
NODE_ENV=development
PORT=3210
HOST=127.0.0.1
LOG_API_REQUESTS=trueStaging
NODE_ENV=staging
PORT=3210
HOST=0.0.0.0
LOG_API_REQUESTS=trueProduction
NODE_ENV=production
PORT=3210
HOST=0.0.0.0
LOG_API_REQUESTS=falseMonitoring and Logging
Built-in Health Check System
The application includes a comprehensive health monitoring system:
Health Check Endpoints:
/api/health/live- Liveness probe (process running)/api/health/ready- Readiness probe (dependencies healthy)/api/health/details- Detailed component health/api/health/history- Historical health data
Status Dashboard:
- Visual status page at
/status - Real-time component health monitoring
- Historical charts with Chart.js
- Uptime percentage tracking
- Auto-refresh every 30 seconds
Docker Health Checks: The Dockerfile includes a built-in HEALTHCHECK:
HEALTHCHECK --interval=30s --timeout=5s --start-period=30s --retries=3 \
CMD curl -fsS http://localhost:3210/api/health/ready || exit 1Health Check Configuration:
- Automatic health sampling every 60 seconds
- Data stored in
health_check_historytable - Configurable via
health_check_configtable - Monitors: Database, Environment, Steam API, Disk, Memory
Using Health Checks:
- Kubernetes: Configure liveness and readiness probes
- Docker Compose: Built-in healthcheck in service definition
- Load Balancers: Point health checks to
/api/health/ready - Monitoring Tools: Query
/api/health/detailsfor metrics
See HEALTH_CHECKS.md for complete documentation.
Application Monitoring
PM2 Monitoring:
bashpm2 monit pm2 logs cs2inspectLog Files:
- Application logs:
logs/out.log - Error logs:
logs/error.log - Nginx logs:
/var/log/nginx/access.log,/var/log/nginx/error.log
- Application logs:
External Monitoring (Recommended):
- Sentry: Error tracking
- LogRocket: Session replay
- New Relic: APM
- Datadog: Infrastructure monitoring
Database Monitoring
# Check database size
mysql -u csinspect -p -e "SELECT table_schema AS 'Database', ROUND(SUM(data_length + index_length) / 1024 / 1024, 2) AS 'Size (MB)' FROM information_schema.TABLES GROUP BY table_schema;"
# Monitor connections
mysql -u csinspect -p -e "SHOW PROCESSLIST;"Backup Strategy
Database Backups
Automated Backup Script (scripts/backup.sh):
#!/bin/bash
BACKUP_DIR="/var/backups/cs2inspect"
DATE=$(date +%Y%m%d_%H%M%S)
BACKUP_FILE="$BACKUP_DIR/cs2inspect_$DATE.sql.gz"
# Create backup
mysqldump -u csinspect -p$DATABASE_PASSWORD csinspect | gzip > $BACKUP_FILE
# Keep only last 7 days
find $BACKUP_DIR -name "cs2inspect_*.sql.gz" -mtime +7 -delete
echo "Backup completed: $BACKUP_FILE"Setup Cron Job:
# Edit crontab
crontab -e
# Add daily backup at 2 AM
0 2 * * * /var/www/cs2inspect-web/scripts/backup.sh >> /var/log/cs2inspect-backup.log 2>&1File Backups
# Backup application files
tar -czf cs2inspect_files_$(date +%Y%m%d).tar.gz \
--exclude='node_modules' \
--exclude='.git' \
/var/www/cs2inspect-webScaling Considerations
Horizontal Scaling
- Load Balancer: Use Nginx or cloud load balancer
- Multiple App Instances: Run multiple PM2 instances or containers
- Database Replication: Setup master-slave replication
- Redis Cache: Add Redis for session and data caching
Vertical Scaling
- Increase server resources (CPU, RAM)
- Optimize database queries
- Enable database query caching
- Use CDN for static assets
Security Best Practices
Environment Variables:
- Never commit
.envfile - Use secrets management (AWS Secrets Manager, Vault)
- Rotate credentials regularly
- Never commit
SSL/TLS:
- Always use HTTPS in production
- Use strong cipher suites
- Enable HSTS header
Database Security:
- Use strong passwords
- Restrict database access by IP
- Enable SSL for database connections
- Regular security updates
Application Security:
- Keep dependencies updated
- Use rate limiting
- Implement CSRF protection
- Sanitize user inputs
- Regular security audits
Rollback Procedure
Quick Rollback
PM2 Rollback:
bash# Revert to previous build git checkout <previous-commit-hash> bun install --frozen-lockfile bun run build pm2 restart cs2inspectDocker Rollback:
bash# Use previous image docker pull cs2inspect-web:previous-tag docker-compose -f docker-compose.coolify.yml up -dVercel Rollback:
- Go to Vercel dashboard
- Click "Deployments"
- Select previous deployment
- Click "Promote to Production"
Health Checks
Endpoint Monitoring
Create health check endpoint:
// server/api/health.ts
export default defineEventHandler(() => {
return {
status: 'ok',
timestamp: new Date().toISOString(),
version: '1.0.0'
}
})Monitoring Script
#!/bin/bash
URL="https://your-domain.com/api/health"
RESPONSE=$(curl -s -o /dev/null -w "%{http_code}" $URL)
if [ $RESPONSE -eq 200 ]; then
echo "✅ Health check passed"
else
echo "❌ Health check failed (HTTP $RESPONSE)"
# Send alert
fiRelated Documentation
- Setup Guide - Development setup
- Architecture - System architecture
- API Reference - API documentation
- Contributing - Contribution guidelines