banatie-service/prod-env/README.md

4.1 KiB

Production Environment

This directory contains the production Docker Compose configuration for running all Banatie services in containers.

Services

  • API Service (port 3000) - REST API for image generation
  • Landing Page (port 3001) - Public website
  • PostgreSQL (port 5460→5432) - Database
  • MinIO (ports 9000-9001) - Object storage with S3 compatibility

Quick Start

1. Setup Secrets

cp secrets.env.example secrets.env
# Edit secrets.env with real values

Required secrets:

  • GEMINI_API_KEY - Your Google Gemini API key

2. Start Services

# From prod-env directory
docker compose up -d

3. Check Status

docker compose ps
docker compose logs -f app      # API logs
docker compose logs -f landing  # Landing logs

4. Stop Services

docker compose down

Deployment to VPS

Initial Setup

# On VPS
cd /path/to/banatie-service
git pull
cd prod-env
cp secrets.env.example secrets.env
# Edit secrets.env with production values
docker compose up -d --build

Updates

# On VPS
cd /path/to/banatie-service/prod-env
git pull
docker compose up -d --build

Environment Variables

Configuration is split into two files:

  • .env - Base configuration (committed to git)

    • Service endpoints (Docker internal: postgres:5432, minio:9000)
    • Database credentials (development values)
    • Storage configuration
    • Application settings
  • secrets.env - Sensitive secrets (NOT committed)

    • API keys (Gemini)
    • Production passwords (if different)
    • Testing keys (optional)

Port Mappings

Service Host Port Container Port Description
API 3000 3000 REST API
Landing 3001 3000 Landing page
PostgreSQL 5460 5432 Database
MinIO API 9000 9000 S3-compatible storage
MinIO UI 9001 9001 Web console

Data Persistence

All data is stored in the parent data/ directory:

../data/
├── postgres/         # Database files
├── storage/          # MinIO storage (4 drives for SNMD)
├── results/          # Generated images
└── uploads/          # Uploaded files

Accessing Services

Database Access

Connect to PostgreSQL from host:

psql -h localhost -p 5460 -U banatie_user -d banatie_db

From another Docker container (same network):

psql -h postgres -p 5432 -U banatie_user -d banatie_db

Troubleshooting

Check service health

docker compose ps

View logs

docker compose logs -f         # All services
docker compose logs -f app     # API only
docker compose logs -f postgres # Database only

Restart specific service

docker compose restart app

Rebuild after code changes

docker compose up -d --build

Reset everything

docker compose down -v  # ⚠️ This deletes volumes!

Production Considerations

  1. Secrets Management

    • Never commit secrets.env
    • Use strong passwords in production
    • Rotate API keys regularly
  2. Database Backups

    • Set up automated backups of data/postgres/
    • Test restore procedures
  3. Resource Limits

    • Add memory/CPU limits to docker-compose.yml if needed
    • Monitor with docker stats
  4. SSL/TLS

    • Use reverse proxy (nginx/traefik) for HTTPS
    • Enable MinIO SSL for production
  5. Monitoring

    • Set up health check endpoints
    • Configure alerts for service failures

Development vs Production

This configuration is for production (all services in Docker).

For development (local API, Docker infrastructure):

  • Use apps/api-service/docker-compose.yml
  • Run pnpm dev from api-service directory
  • Connects to Docker services via localhost:5460 and localhost:9000