Skip to main content

Deployment

This guide covers deploying UAPK Gateway to production environments.

Deployment Options​

  • Single VM - Simple deployment on a single virtual machine - Single VM

  • Caddy (Recommended) - HTTPS reverse proxy with automatic certificates - Caddy Setup

  • Backups - Database and configuration backup strategies - Backups

  • Monitoring - Observability and alerting setup - Monitoring

Architecture Overview​

Quick Start (Docker Compose)​

For development and testing:

# Clone repository
git clone https://github.com/UAPK/gateway.git
cd gateway

# Start services
docker compose up -d

# Check status
docker compose ps

Production Requirements​

Hardware​

ComponentMinimumRecommended
CPU2 cores4+ cores
RAM4 GB8+ GB
Disk20 GB SSD100+ GB SSD

Software​

ComponentVersion
LinuxUbuntu 22.04+ or Debian 12+
Docker24.0+
PostgreSQL15+
Python3.11+ (if not using Docker)

Network​

PortServiceAccess
443HTTPSPublic
80HTTP (redirect)Public
8000Gateway APIInternal
5432PostgreSQLInternal

Configuration​

Environment Variables​

# Core settings
GATEWAY_HOST=0.0.0.0
GATEWAY_PORT=8000
GATEWAY_ENV=production

# Database
DATABASE_URL=postgresql://user:pass@db:5432/uapk_gateway

# Security
SECRET_KEY=your-256-bit-secret-key
GATEWAY_SIGNING_KEY_FILE=/etc/uapk-gateway/keys/signing.pem

# Logging
LOG_LEVEL=INFO
LOG_FORMAT=json

# Optional
GATEWAY_APPROVAL_EXPIRY_HOURS=24
GATEWAY_MAX_CONNECTIONS=100

Configuration File​

# config.yaml
server:
host: 0.0.0.0
port: 8000
workers: 4

database:
url: postgresql://user:pass@db:5432/uapk_gateway
pool_size: 20

security:
signing_key_file: /etc/uapk-gateway/keys/signing.pem
token_expiry_hours: 1

logging:
level: INFO
format: json
output: stdout

Deployment Checklist​

Pre-Deployment​

  • Generate signing key pair
  • Configure secrets management
  • Set up PostgreSQL database
  • Configure TLS certificates
  • Set up monitoring/alerting
  • Document runbook

Deployment​

  • Deploy database first
  • Run database migrations
  • Deploy gateway application
  • Configure reverse proxy
  • Verify health checks
  • Test API endpoints

Post-Deployment​

  • Verify log chain initialization
  • Create initial organization
  • Set up backup schedule
  • Configure monitoring alerts
  • Document deployment details

High Availability​

For high availability, deploy multiple gateway instances:

Considerations​

ComponentHA Strategy
GatewayMultiple instances behind load balancer
DatabasePrimary-replica with failover
Signing KeyShared via secrets manager
SessionsStateless JWT tokens

Troubleshooting​

Common Issues​

IssueCheck
Connection refusedFirewall rules, service status
Database errorsConnection string, permissions
TLS errorsCertificate validity, chain
Auth failuresToken expiry, key configuration

Health Check​

# Check gateway health
curl http://localhost:8000/api/v1/gateway/health

# Check database connection
docker compose exec gateway python -c "from app.db import engine; engine.connect()"