Deployment Configuration
All static sites are deployed via Cloudflare Pages with GitHub integration.
Cloudflare Pages Projects
Build Configuration
| Project | Build Command | Output Dir |
|---|---|---|
| battlesbit-landing | npm run build | dist |
| battlesbit (PWA) | yarn build | dist |
| battlesbit-admin | yarn build | dist |
| battlesbit-docs | yarn build | out |
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 Project | GitHub Repo | Branch |
|---|---|---|
| battlesbit-landing | battlesbit/landing | main |
| battlesbit | battlesbit/public | main |
| battlesbit-admin | battlesbit/admin | main |
| battlesbit-docs | battlesbit/docs | main |
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
- Push to
mainbranch - Cloudflare Pages detects change
- Runs build command
- Deploys to production domain
- CDN cache invalidation
Preview Deployment
- Push to any non-main branch
- Cloudflare Pages creates preview
- Unique URL generated (e.g.,
abc123.pages.dev) - PR comment with preview link
Dev Server Infrastructure
Development services run on dedicated infrastructure:
| Service | Domain | Host |
|---|---|---|
| Backend API | service-dev.battlesbit.ir | Sindad |
| ArgoCD | argocd-dev.battlesbit.ir | Sindad |
| Grafana | grafana-dev.battlesbit.ir | Sindad |
| Rancher | rancher-dev.battlesbit.ir | Sindad |
| Helpdesk | helpdesk-dev.battlesbit.ir | Sindad |
IP Addresses
| Variable | Default | Description |
|---|---|---|
hostinger_ip | 77.37.37.180 | Hostinger server |
sindad_dev_ip | 162.223.89.45 | Dev 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:
| Variable | Type | Description |
|---|---|---|
| cloudflare_email | env | Account email |
| cloudflare_api_key | env (sensitive) | API key |
| cloudlare_account_id | env | Account ID |
| hostinger_ip | terraform | Hostinger IP |
| sindad_dev_ip | terraform | Dev cluster IP |
| main_domain | terraform | Primary domain |
Adding New Deployment
To add a new Cloudflare Pages project:
- 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"
}
}
}- 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"
}- 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
}- Run terraform:
terraform plan
terraform applyLast updated on