File tree Expand file tree Collapse file tree
PocketDDD.BlazorClient/PocketDDD.BlazorClient/wwwroot Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44 branches-ignore :
55 - ' main'
66
7-
87jobs :
98 deploy_to_test :
109 uses : ./.github/workflows/DeployEverything.yml
1413 AZURE_CREDENTIALS : ${{ secrets.AZURE_CREDENTIALS }}
1514 AZURE_STATIC_WEB_APPS_API_TOKEN : ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN }}
1615 TERRAFORM_STATE_ACCESS_KEY : ${{ secrets.TERRAFORM_STATE_ACCESS_KEY }}
16+ CLOUDFLARE_TOKEN : ${{ secrets.CLOUDFLARE_TOKEN }}
17+ CLOUDFLARE_ACCOUNT_ID : ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
Original file line number Diff line number Diff line change 1313 required : true
1414 TERRAFORM_STATE_ACCESS_KEY :
1515 required : true
16+ CLOUDFLARE_TOKEN :
17+ required : true
18+ CLOUDFLARE_ACCOUNT_ID :
19+ required : true
1620
1721env :
1822 AZURE_WEBAPP_PACKAGE_PATH : PocketDDD.Server.WebAPI/publish
4044 - run : |
4145 terraform init -backend-config="key=${{ inputs.env }}.terraform.tfstate"
4246
43- terraform apply -auto-approve -- var-file ../tfvars/${{ inputs.env }}.tfvars
47+ terraform apply -auto-approve -var-file ../tfvars/${{ inputs.env }}.tfvars -var 'cloudflare_account_id=${{ secrets.CLOUDFLARE_ACCOUNT_ID }}'
4448 env:
4549 ARM_ACCESS_KEY: ${{ secrets.TERRAFORM_STATE_ACCESS_KEY }}
50+ CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_TOKEN }}
4651
4752 build_api_server :
4853 runs-on : ubuntu-latest
Original file line number Diff line number Diff line change 1+ name : Deploy Branch Push
2+ on :
3+ push :
4+ branches :
5+ - ' main'
6+
7+ jobs :
8+ deploy_to_test :
9+ uses : ./.github/workflows/DeployEverything.yml
10+ with :
11+ env : " Production"
12+ secrets :
13+ AZURE_CREDENTIALS : ${{ secrets.AZURE_CREDENTIALS }}
14+ AZURE_STATIC_WEB_APPS_API_TOKEN : ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN }}
15+ TERRAFORM_STATE_ACCESS_KEY : ${{ secrets.TERRAFORM_STATE_ACCESS_KEY }}
16+ CLOUDFLARE_TOKEN : ${{ secrets.CLOUDFLARE_TOKEN }}
17+ CLOUDFLARE_ACCOUNT_ID : ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
Original file line number Diff line number Diff line change 2727 Blazor . start ( {
2828 environment : "Development"
2929 } ) ;
30+ } else if ( window . location . hostname . includes ( "test2" ) ) {
31+ console . info ( "Env = Test2" )
32+ Blazor . start ( {
33+ environment : "Test2"
34+ } ) ;
3035 } else if ( window . location . hostname . includes ( "test" ) ) {
3136 console . info ( "Env = Test" )
3237 Blazor . start ( {
Original file line number Diff line number Diff line change @@ -7,8 +7,6 @@ resource "azurerm_static_web_app" "blazor-client" {
77 sku_size = var. client_sku_size
88
99 app_settings = {
10- " ASPNETCORE_ENVIRONMENT" : " ${ var . env } "
11- " DOTNET_ENVIRONMENT" : " ${ var . env } "
1210 " apiUrl" : " https://pocketddd-${ var . env } -api-server-web-app.azurewebsites.net/api/"
1311 " fakeBackend" : " false"
1412 }
@@ -21,3 +19,22 @@ resource "azurerm_key_vault_secret" "blazor_client_deployment_token" {
2119 value = azurerm_static_web_app. blazor-client . api_key
2220 key_vault_id = azurerm_key_vault. key_vault . id
2321}
22+
23+ data "cloudflare_zone" "dns_zone" {
24+ account_id = var. cloudflare_account_id
25+ name = " dddsouthwest.com"
26+ }
27+
28+ resource "cloudflare_record" "cname_record" {
29+ zone_id = data. cloudflare_zone . dns_zone . id
30+ name = local. subdomain
31+ value = azurerm_static_web_app. blazor-client . default_host_name
32+ type = " CNAME"
33+ ttl = 3600
34+ }
35+
36+ resource "azurerm_static_web_app_custom_domain" "custom_domain" {
37+ static_web_app_id = azurerm_static_web_app. blazor-client . id
38+ domain_name = " ${ cloudflare_record . cname_record . name } .${ data . cloudflare_zone . dns_zone . name } "
39+ validation_type = " cname-delegation"
40+ }
Original file line number Diff line number Diff line change 11locals {
22 resource_prefix = " pocketddd-${ var . env } "
33 sql_server_name = " ${ local . resource_prefix } -sql-server"
4+ subdomain = var. env == " prod" ? " pocket" : " pocket-${ var . env } "
45}
Original file line number Diff line number Diff line change 11output "api_server_url" {
22 value = " https://${ azurerm_linux_web_app . api_server_web_app . default_hostname } /"
33}
4+
5+ # output "client_app_public_url" {
6+ # value =
7+ # }
Original file line number Diff line number Diff line change @@ -13,6 +13,10 @@ terraform {
1313 source = " hashicorp/random"
1414 version = " 3.6.1"
1515 }
16+ cloudflare = {
17+ source = " cloudflare/cloudflare"
18+ version = " ~> 4.0"
19+ }
1620 }
1721}
1822
Original file line number Diff line number Diff line change @@ -39,3 +39,8 @@ variable "client_sku_size" {
3939 nullable = false
4040 type = string
4141}
42+
43+ variable "cloudflare_account_id" {
44+ nullable = false
45+ type = string
46+ }
Original file line number Diff line number Diff line change 11env = " prod"
2- sql_db_sku = " S0 "
3- sql_max_storage = " 10 "
2+ sql_db_sku = " Basic "
3+ sql_max_storage = " 2 "
44api_app_service_sku = " B1"
5- api_always_on = true
6- client_sku_tier = " Standard"
7- client_sku_size = " Standard"
5+ api_always_on = false
6+ client_sku_tier = " Free"
7+ client_sku_size = " Free"
8+
9+ # Real prod values
10+ # env = "prod"
11+ # sql_db_sku = "S0"
12+ # sql_max_storage = "10"
13+ # api_app_service_sku = "B1"
14+ # api_always_on = true
15+ # client_sku_tier = "Standard"
16+ # client_sku_size = "Standard"
You can’t perform that action at this time.
0 commit comments