Polari
Reference

Environment configuration

Source
polari-rf-node/docs/ENVIRONMENT_CONFIGURATION.md in the suite repository. This page is generated from it; edits go there.

This document describes the tiered environment variable system used across the PRF project.

Overview

The PRF uses a three-tier configuration system that provides flexibility for different deployment scenarios:

TierNameWhen AppliedHow to Change
Tier 1Build-timeDuring Docker image buildRebuild image
Tier 2Startup-timeAt container startupEdit .env or pass env vars
Tier 3RuntimeWhile app is runningVia UI or API

Priority: Tier 3 > Tier 2 > Tier 1 (higher tiers override lower tiers)

Configuration Files

Root Level Files

FileTierPurpose
.env.defaults1Base defaults baked into images
.env2Startup-time overrides
docker-compose.yml2Container orchestration with env var support

Frontend (Angular)

FileTierPurpose
src/environments/environment.ts1Bare metal/local development
src/environments/environment-dev.ts1Docker development build
src/environments/environment.prod.ts1Production build
src/assets/runtime-config.json2Startup-time overrides
RuntimeConfigService3Runtime configuration service
PolariService3Runtime connection settings

Backend (Python)

FileTierPurpose
config.yaml1Base YAML configuration
Environment variables2Startup-time overrides
config_loader.py2/3Configuration loader with runtime support

Environment Variables Reference

Backend Configuration

VariableTierDefaultDescription
BACKEND_URL2localhostBackend server hostname
BACKEND_HTTP_PORT23000HTTP port
BACKEND_HTTPS_PORT22096HTTPS port (Cloudflare-compatible)
DEPLOY_ENV2developmentEnvironment name
LOG_LEVEL2/3INFOLogging level (DEBUG, INFO, WARNING, ERROR)
CORS_ENABLED2/3trueEnable CORS

Frontend Configuration

VariableTierDefaultDescription
FRONTEND_URL2localhostFrontend server hostname
FRONTEND_HTTP_PORT24200HTTP port
FRONTEND_HTTPS_PORT22087HTTPS port (Cloudflare-compatible)
BACKEND_PREFER_HTTPS2/3falseUse HTTPS for backend connections

SSL Configuration

VariableTierDefaultDescription
SSL_ENABLED2trueEnable SSL/HTTPS
SSL_CERT_PATH2/app/certs/prf-proxy.crtSSL certificate path
SSL_KEY_PATH2/app/certs/prf-proxy.keySSL private key path

Connection Settings (Runtime Configurable)

VariableTierDefaultDescription
CONNECTION_RETRY_INTERVAL2/33000Retry interval in milliseconds
CONNECTION_MAX_RETRY_TIME2/360000Max retry time in milliseconds
CONNECTION_TIMEOUT2/330000Request timeout in milliseconds

Usage Examples

1. Default Docker Development

# Uses defaults from .env.defaults and .env
docker-compose up

2. Override at Startup (Tier 2)

# Override backend URL
BACKEND_URL=192.168.1.100 docker-compose up

# Override multiple settings
BACKEND_URL=api.example.com BACKEND_HTTPS_PORT=443 docker-compose up

3. Edit .env File (Tier 2)

# Edit .env to change defaults
vim .env

# Then start containers
docker-compose up

4. Runtime Configuration via Frontend UI (Tier 3)

The Polari Configuration component allows changing:

  • Backend URL and port
  • Protocol (HTTP/HTTPS)
  • Connection retry settings

Changes take effect immediately without restart.

5. Runtime Configuration via Python API (Tier 3)

from config_loader import config

# Change configuration at runtime
config.set_runtime('backend.port', 3001)
config.set_runtime('logging.level', 'DEBUG')

# Check which tier a value comes from
print(config.get_config_tier('backend.port'))  # 'tier3_runtime'

# View all tier values
print(config.get_all_tiers('backend.port'))

Port Reference

Cloudflare-Compatible HTTPS Ports

These ports are supported by Cloudflare's proxy:

  • 443, 2053, 2083, 2087, 2096, 8443

PRF Port Allocation

ServiceHTTPHTTPS
Frontend42002087
Backend30002096

PSC Port Allocation (for reference)

ServiceHTTPHTTPS
Frontend42002053
Backend80802083

Best Practices

  1. Never commit secrets - Use environment variables for passwords/keys
  2. Use Tier 2 for deployment-specific settings - Different URLs per environment
  3. Use Tier 3 for user preferences - Connection settings that users may want to change
  4. Keep Tier 1 as sensible defaults - Should work out of the box for development

Troubleshooting

Check Effective Configuration

Frontend (Browser Console):

// In Angular app
runtimeConfigService.getCurrentConfig()

Backend (Python):

from config_loader import config
print(config.get_all_tiers('backend.port'))

Configuration Not Taking Effect

  1. Check tier priority (Tier 3 > Tier 2 > Tier 1)
  2. For Tier 2, restart the container
  3. For Tier 1, rebuild the image: docker-compose build --no-cache

SSL Certificate Issues

# Generate certificates
./generate-prf-certs.sh dev

# Verify certificates exist
ls -la prf-proxy/certs/

← All documentation