Configuration/Env Variables

Environment Variables

Comprehensive reference for configuring Hatch microservices. Each service requires specific keys to communicate with AWS, RabbitMQ, and Redis.

GLOBAL SCHEMA SECRETS REQUIRED MONOREPO SCOPED

API Gateway

Handles authentication, project management, and job publishing.

VariableDescription
PORTInternal port the Gin server listens on (default: 8080).
GITHUB_CLIENT_IDOAuth application client ID from GitHub Developer settings.
GITHUB_CLIENT_SECRETOAuth application secret for exchanging codes for tokens.
JWT_SECRETHigh-entropy string used to sign session tokens.
DATABASE_URLPostgreSQL connection string (e.g., postgres://user:pass@host:5432/db).
RABBITMQ_URLConnection string for the message broker.
REDIS_URLConnection string for log persistence and real-time streams.

Builder Worker

Orchestrates git cloning, Docker builds, and ECR pushing.

VariableDescription
AWS_REGIONThe AWS region where ECR repositories are located.
ECR_REGISTRYFull URI of your private ECR registry (e.g., <id>.dkr.ecr.<region>.amazonaws.com).
ECR_REPOSITORYBase name for storing build artifacts (default: hatch-builds).
REDIS_URLShared with API for streaming build logs back to the dashboard.
RABBITMQ_URLShared with API to consume BuildJob events.

Deployer Worker

Provisions and updates ECS Fargate tasks and ALB routing rules.

VariableDescription
ECS_CLUSTER_NAMEThe name of the cluster provisioned via Terraform.
ALB_LISTENER_ARNARN of the ALB listener where rules will be injected.
VPC_IDThe ID of the target VPC for task networking.
SUBNET_A / SUBNET_BPrivate subnets where Fargate tasks will be launched.
TASK_EXECUTION_ROLE_ARNIAM Role providing task permissions to ECR and CloudWatch.

Web Frontend

Next.js application providing the control plane UI.

VariableDescription
NEXT_PUBLIC_API_URLPublic URL of the API Gateway (used for client-side fetches).
NEXT_PUBLIC_WS_URLWebSocket endpoint for real-time log streaming (optional if using relative paths).

Security Best Practices

  • Never commit .env files to source control. They are ignored by default via the root .gitignore.
  • In production, prefer using AWS Secrets Manager or Parameter Store instead of raw environment variables where possible.
  • Rotate your JWT_SECRET and GITHUB_CLIENT_SECRET regularly to minimize exposure.