Skip to main content

Environment Variables

This document lists all environment variables used by FastGateway components.

Backend Environment Variables

VariableRequiredDescriptionExample
DATABASE_URLYesPostgreSQL connection stringpostgres://user:pass@localhost:5432/fastgateway
JWT_SECRETYesSecret key for JWT token signing (min 32 characters)your-super-secret-jwt-key-min-32-chars
ENCRYPTION_KEYYesKey for encrypting sensitive data (32 characters)your-32-character-encryption-key
API_PORTNoPort for the API server (default: 8080)8080
CORS_ALLOWED_ORIGINSNoComma-separated list of allowed CORS originshttp://localhost:3000,https://app.example.com
ADMIN_USERNAMEYesInitial admin usernameadmin
ADMIN_PASSWORDYesInitial admin passwordsecurepassword123
ADMIN_EMAILYesInitial admin emailadmin@example.com

Kubernetes Configuration

VariableRequiredDescriptionExample
KUBE_CONFIG_PATHNoPath to kubeconfig file (for local development)~/.kube/config
KUBE_CONTEXTNoKubernetes context to usemy-cluster
KUBE_IN_CLUSTERNoSet to true when running inside Kubernetestrue
KUBE_TOKENNoService account token for Kubernetes APIeyJhbGciOi...
KUBE_API_SERVERNoKubernetes API server URLhttps://kubernetes.default.svc

Frontend Environment Variables

VariableRequiredDescriptionExample
NEXT_PUBLIC_API_URLYesBackend API URLhttp://localhost:8080

Example .env File

Backend (.env)

# Database Configuration
DATABASE_URL=postgres://fastgateway:password@localhost:5432/fastgateway?sslmode=disable

# Security
JWT_SECRET=your-super-secret-jwt-key-must-be-at-least-32-characters-long
ENCRYPTION_KEY=your-32-character-encryption-key

# Server Configuration
API_PORT=8080
CORS_ALLOWED_ORIGINS=http://localhost:3000

# Initial Admin User
ADMIN_USERNAME=admin
ADMIN_PASSWORD=changeme123
ADMIN_EMAIL=admin@example.com

# Kubernetes Configuration (for local development)
KUBE_CONFIG_PATH=~/.kube/config
KUBE_CONTEXT=kind-fastgateway

# Kubernetes Configuration (for in-cluster deployment)
# KUBE_IN_CLUSTER=true

Frontend (.env.local)

NEXT_PUBLIC_API_URL=http://localhost:8080

Docker Compose Example

version: '3.8'
services:
postgres:
image: postgres:15
environment:
POSTGRES_USER: fastgateway
POSTGRES_PASSWORD: password
POSTGRES_DB: fastgateway
ports:
- "5432:5432"
volumes:
- postgres_data:/var/lib/postgresql/data

backend:
image: fastgateway/backend:latest
environment:
DATABASE_URL: postgres://fastgateway:password@postgres:5432/fastgateway?sslmode=disable
JWT_SECRET: your-super-secret-jwt-key-must-be-at-least-32-characters-long
ENCRYPTION_KEY: your-32-character-encryption-key
API_PORT: "8080"
CORS_ALLOWED_ORIGINS: http://localhost:3000
ADMIN_USERNAME: admin
ADMIN_PASSWORD: changeme123
ADMIN_EMAIL: admin@example.com
KUBE_CONFIG_PATH: /root/.kube/config
ports:
- "8080:8080"
volumes:
- ~/.kube:/root/.kube:ro
depends_on:
- postgres

frontend:
image: fastgateway/frontend:latest
environment:
NEXT_PUBLIC_API_URL: http://localhost:8080
ports:
- "3000:3000"
depends_on:
- backend

volumes:
postgres_data:

Generating Secure Keys

JWT Secret

# Generate a random 64-character JWT secret
openssl rand -base64 48

Encryption Key

# Generate a 32-character encryption key
openssl rand -base64 24

Security Best Practices

  1. Never commit .env files to version control
  2. Use different secrets for each environment (development, staging, production)
  3. Rotate secrets regularly in production environments
  4. Use a secrets manager (like Kubernetes Secrets, HashiCorp Vault, or AWS Secrets Manager) in production
  5. Restrict file permissions on .env files (chmod 600 .env)