Deployment Guide
Deployment Guide
Section titled âDeployment GuideâDeploy Pocat to production environments with these platform-specific guides.
Docker Deployment
Section titled âDocker DeploymentâBasic Docker Setup
Section titled âBasic Docker SetupâFROM node:18-alpine
WORKDIR /appCOPY package*.json ./RUN npm install
COPY . .RUN npm run build
EXPOSE 3333CMD ["npm", "start"]Docker Compose
Section titled âDocker Composeâversion: '3.8'services: pocat: build: . ports: - "3333:3333" environment: - NODE_ENV=production - DB_CONNECTION=sqlite volumes: - ./storage:/app/storage - ./downloads:/app/downloadsCloud Platforms
Section titled âCloud PlatformsâRailway
Section titled âRailwayâ- Connect your GitHub repository
- Set environment variables:
NODE_ENV=productionPORT=3333
- Deploy automatically on push
# Install Heroku CLIheroku create your-pocat-appheroku config:set NODE_ENV=productiongit push heroku mainDigitalOcean App Platform
Section titled âDigitalOcean App Platformâname: pocatservices:- name: api source_dir: / github: repo: your-username/pocat branch: main run_command: npm start environment_slug: node-js instance_count: 1 instance_size_slug: basic-xxs envs: - key: NODE_ENV value: productionVPS Deployment
Section titled âVPS DeploymentâUbuntu/Debian Setup
Section titled âUbuntu/Debian Setupâ# Install Node.jscurl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -sudo apt-get install -y nodejs
# Install PM2sudo npm install -g pm2
# Clone and setupgit clone https://github.com/your-username/pocat.gitcd pocatnpm installnpm run build
# Start with PM2pm2 start npm --name "pocat" -- startpm2 startuppm2 saveNginx Configuration
Section titled âNginx Configurationâserver { listen 80; server_name your-domain.com;
location / { proxy_pass http://localhost:3333; 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; }}Environment Variables
Section titled âEnvironment VariablesâRequired Variables
Section titled âRequired VariablesâNODE_ENV=productionPORT=3333DB_CONNECTION=sqliteOptional Variables
Section titled âOptional Variablesâ# Database (if using MySQL/PostgreSQL)DB_HOST=localhostDB_PORT=3306DB_USER=pocatDB_PASSWORD=your_passwordDB_DATABASE=pocat
# File StorageSTORAGE_PATH=/app/storageDOWNLOADS_PATH=/app/downloads
# Rate LimitingRATE_LIMIT_MAX=100RATE_LIMIT_WINDOW=900000Security Considerations
Section titled âSecurity ConsiderationsâAPI Security
Section titled âAPI Securityâ- Use HTTPS in production
- Implement rate limiting
- Add authentication if needed
- Validate all inputs
File Security
Section titled âFile Securityâ- Restrict file access permissions
- Use separate storage for downloads
- Implement file cleanup policies
Network Security
Section titled âNetwork Securityâ# Firewall setup (Ubuntu)sudo ufw allow sshsudo ufw allow 80sudo ufw allow 443sudo ufw enableMonitoring
Section titled âMonitoringâHealth Check Endpoint
Section titled âHealth Check Endpointâ// Add to your routesapp.get('/health', (req, res) => { res.json({ status: 'ok', timestamp: new Date().toISOString(), uptime: process.uptime() });});PM2 Monitoring
Section titled âPM2 Monitoringâ# Monitor processespm2 monit
# View logspm2 logs pocat
# Restart if neededpm2 restart pocatScaling
Section titled âScalingâHorizontal Scaling
Section titled âHorizontal Scalingâ- Use load balancer (nginx, HAProxy)
- Shared storage for downloads
- Database clustering if needed
Vertical Scaling
Section titled âVertical Scalingâ- Increase server resources
- Optimize Node.js memory usage
- Use clustering module