Skip to Content
InfrastructureDeployments

Deployment Configuration

All static sites are deployed via Cloudflare Pages with GitHub integration.


Cloudflare Pages Projects

Build Configuration

ProjectBuild CommandOutput Dir
battlesbit-landingnpm run builddist
battlesbit (PWA)yarn builddist
battlesbit-adminyarn builddist
battlesbit-docsyarn buildout

Deployment Settings

All projects share these settings:

build_config { build_caching = false } source { type = "github" config { deployments_enabled = true pr_comments_enabled = true preview_branch_includes = ["*"] preview_deployment_setting = "all" production_deployment_enabled = true } }

GitHub Integration

Each Cloudflare Pages project connects to a GitHub repository:

Pages ProjectGitHub RepoBranch
battlesbit-landingbattlesbit/landingmain
battlesbitbattlesbit/publicmain
battlesbit-adminbattlesbit/adminmain
battlesbit-docsbattlesbit/docsmain

Features

  • Auto Deploy: Pushes to main trigger production deployments
  • Preview Deployments: All branches get preview URLs
  • PR Comments: Build status posted to pull requests

Deployment Flow

┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │ GitHub │────▶│ Cloudflare │────▶│ Live │ │ Push │ │ Pages │ │ Site │ └─────────────┘ └─────────────┘ └─────────────┘ │ │ │ ▼ │ ┌─────────────┐ │ │ Build │ │ │ Logs │ │ └─────────────┘ ┌─────────────┐ │ PR Comment │ │ (status) │ └─────────────┘

Production Deployment

  1. Push to main branch
  2. Cloudflare Pages detects change
  3. Runs build command
  4. Deploys to production domain
  5. CDN cache invalidation

Preview Deployment

  1. Push to any non-main branch
  2. Cloudflare Pages creates preview
  3. Unique URL generated (e.g., abc123.pages.dev)
  4. PR comment with preview link

Dev Server Infrastructure

Development services run on dedicated infrastructure:

ServiceDomainHost
Backend APIservice-dev.battlesbit.irSindad
ArgoCDargocd-dev.battlesbit.irSindad
Grafanagrafana-dev.battlesbit.irSindad
Rancherrancher-dev.battlesbit.irSindad
Helpdeskhelpdesk-dev.battlesbit.irSindad

IP Addresses

VariableDefaultDescription
hostinger_ip77.37.37.180Hostinger server
sindad_dev_ip162.223.89.45Dev Kubernetes cluster

Environment Variables

Required for Terraform

export CLOUDFLARE_EMAIL="your@email.com" export CLOUDFLARE_API_KEY="your-api-key" export CLOUDFLARE_ACCOUNT_ID="your-account-id"

Terraform Cloud Variables

These are configured in Terraform Cloud workspace:

VariableTypeDescription
cloudflare_emailenvAccount email
cloudflare_api_keyenv (sensitive)API key
cloudlare_account_idenvAccount ID
hostinger_ipterraformHostinger IP
sindad_dev_ipterraformDev cluster IP
main_domainterraformPrimary domain

Adding New Deployment

To add a new Cloudflare Pages project:

  1. Create terraform file in domains/:
resource "cloudflare_pages_project" "new_project" { name = "battlesbit-newproject" account_id = var.cloudlare_account_id production_branch = "main" build_config { build_caching = false build_command = "yarn build" destination_dir = "dist" } source { type = "github" config { deployments_enabled = true owner = "battlesbit" pr_comments_enabled = true preview_branch_includes = ["*"] preview_deployment_setting = "all" production_branch = "main" production_deployment_enabled = true repo_name = "new-repo" } } }
  1. Add custom domain (optional):
resource "cloudflare_pages_domain" "new_domain" { account_id = var.cloudlare_account_id project_name = cloudflare_pages_project.new_project.name domain = "new.battlesbit.ir" }
  1. Add DNS record:
resource "cloudflare_record" "new-cname" { zone_id = data.cloudflare_zone.battlesbit-ir.id name = "new" content = cloudflare_pages_project.new_project.subdomain type = "CNAME" ttl = 1 proxied = true }
  1. Run terraform:
terraform plan terraform apply
Last updated on