Skip to content
This repository has been archived by the owner on Mar 3, 2023. It is now read-only.

Commit

Permalink
Task/ssr bug (#396)
Browse files Browse the repository at this point in the history
* fix: append pid to temp folder
normalise ssr app in aks tf

* fix: disable cypress

* fix: cdn endpoint

* fix: update csr to use latest core set up

* fix: unnecessary var passed in to redis server-side app

* fix: correct aks cluster

* fix: new urls depracating old ones

* fix: add acme inline support for TLS provisioning

* fix: disable helmet in the app

* fix: create redirect

* fix: test snapshot

* fix: export header

* fix: redirect ... maybe

* fix: yumido homepage pressed from header
  • Loading branch information
dnitsch authored Jul 21, 2020
1 parent c1511ab commit db753f2
Show file tree
Hide file tree
Showing 29 changed files with 257 additions and 153 deletions.
6 changes: 3 additions & 3 deletions packages/scaffolding-cli/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,16 @@ const files: Array<BuildReplaceInput> = [
"tf_state_key: stacks-webapp": `tf_state_key: %REPLACE_ME_FOR_STATE_KEY_FOR_MY_APP%`,
"deploy/azure/app/kube": "deploy/azure/app",
"terraform_state_workspace: dev": "terraform_state_workspace: %REPLACE_ME_FOR_WORKSPACE_NAME_IN_EACH_STAGE%",
"docker_container_registry_name: amidostacksnonproduksnode": "docker_container_registry_name: REPLACE_ME_FOR_CONTAINER_REGISTRY",
"amido-stacks-nonprod-uks-node": "REPLACE_ME_FOR_CLOUD_RESOURCE_NAME"
"docker_container_registry_name: amidostacksnonprodeuncore": "docker_container_registry_name: REPLACE_ME_FOR_CONTAINER_REGISTRY",
"amido-stacks-nonprod-eun-core": "REPLACE_ME_FOR_CLOUD_RESOURCE_NAME"
}
}
]

describe("ssr mapper tests", () => {
it("to_folders return an array of objects", () => {
const test: Array<FolderMap> = staticConf.ssr.folderMap
expect(test.length).toBe(11)
expect(test.length).toBe(10)
})
it("in_files return an array of objects and cloud should be default", () => {
const test: Array<BuildReplaceInput> = ssr.inFiles({ projectName: projName, businessObj: biz, networkObj: network, cloudObj: cloud, scmObj: sourceControl, terraformObj: terraform})
Expand Down
4 changes: 0 additions & 4 deletions packages/scaffolding-cli/src/domain/config/static.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@
"src": "shared/_gitignore",
"dest": "./.gitignore"
},
{
"src": "build/azDevops/azure/k8s_manifests/aks",
"dest": "build/azDevops/azure/k8s_manifests"
},
{
"src": "build/azDevops/azure/templates",
"dest": "build/azDevops/azure/templates"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ export const inFiles = ({
"tf_state_key: stacks-webapp-csr": `tf_state_key: %REPLACE_ME_FOR_STATE_KEY_FOR_MY_APP%`,
"deploy/azure/app/csr": "deploy/azure/app",
"terraform_state_workspace: dev": "terraform_state_workspace: %REPLACE_ME_FOR_WORKSPACE_NAME_IN_EACH_STAGE%",
"nonprod.amidostacks.com": `${networkObj.baseDomain}`
"nonprod.amidostacks.com": `${networkObj.baseDomain}`,
"amido-stacks-nonprod-eun-core": "REPLACE_ME_FOR_CLOUD_RESOURCE_NAME"
}
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ export const inFiles = ({
"tf_state_key: stacks-webapp": `tf_state_key: %REPLACE_ME_FOR_STATE_KEY_FOR_MY_APP%`,
"deploy/azure/app/kube": "deploy/azure/app",
"terraform_state_workspace: dev": "terraform_state_workspace: %REPLACE_ME_FOR_WORKSPACE_NAME_IN_EACH_STAGE%",
"docker_container_registry_name: amidostacksnonproduksnode": "docker_container_registry_name: REPLACE_ME_FOR_CONTAINER_REGISTRY",
"amido-stacks-nonprod-uks-node": "REPLACE_ME_FOR_CLOUD_RESOURCE_NAME"
"docker_container_registry_name: amidostacksnonprodeuncore": "docker_container_registry_name: REPLACE_ME_FOR_CONTAINER_REGISTRY",
"amido-stacks-nonprod-eun-core": "REPLACE_ME_FOR_CLOUD_RESOURCE_NAME"
}
}
]
Expand Down
4 changes: 2 additions & 2 deletions packages/scaffolding-cli/src/domain/workers/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export async function renameJavastyle(inPath: string, match: string | RegExp, re
try {
const newPath = resolve(inPath, replaceString)
const oldPath = resolve(inPath, match as string)
const tmpPath = resolve(tmpdir(), replaceString.replace(/\//g, "-"))
const tmpPath = resolve(tmpdir(), `${replaceString.replace(/\//g, "-")}_${process.ppid}`)
// workaround to ensure all types of namespaces can be accomodated
await copy(oldPath, tmpPath)
await remove(inPath)
Expand Down Expand Up @@ -192,7 +192,7 @@ export class Utils {
const fsResponse: TempCopy = {} as TempCopy
try {
const newDirectory: string = resolve(process.cwd(), directoryName)
const tempDirectory: string = resolve(tmpdir(), directoryName)
const tempDirectory: string = resolve(tmpdir(), `${directoryName}_${process.ppid}`)
// precaution to make sure no files from previous run are polluting the process
await remove(tempDirectory)
// blanket copy templates out
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ stages:
cypress_e2e_env_vars:
PORT: 3000
APP_BASE_URL: "http://localhost"
MENU_API_URL: "https://api.demo.nonprod.amidostacks.com/api/menu"
MENU_API_URL: "https://dev-netcore-api.nonprod.amidostacks.com/api/menu"
APP_BASE_PATH: ""
NODE_ENV: dev
# avoid warnings about terminal
Expand Down Expand Up @@ -183,8 +183,9 @@ stages:
TF_VAR_name_stage: dev,
TF_VAR_dns_zone: nonprod.amidostacks.com,
TF_VAR_dns_record: csr-app,
TF_VAR_app_insights_name: "amido-stacks-nonprod-eun-core",
TF_VAR_create_dns_zone: false,
TF_VAR_dns_resource_group: amido-stacks-nonprod-uks-node,
TF_VAR_dns_resource_group: amido-stacks-nonprod-eun-core,
TF_VAR_response_header_cdn: '[
{
action: "Append",
Expand Down Expand Up @@ -235,6 +236,7 @@ stages:
storage_account_name: $[ dependencies.AppInfraDev.outputs['tfoutputs.storage_account_name'] ]
storage_account_key: $[ dependencies.AppInfraDev.outputs['tfoutputs.storage_account_key'] ]
dns_name: $[ dependencies.AppInfraDev.outputs['tfoutputs.dns_name'] ]
app_insights_instrumentation_key: $[ dependencies.AppInfraDev.outputs['tfoutputs.app_insights_instrumentation_key'] ]
pool:
vmImage: ubuntu-18.04
environment: dev
Expand All @@ -256,7 +258,7 @@ stages:
build_command: 'npm run build'
build_vars: {
NODE_ENV: production,
MENU_API_URL: "https://app.nonprod.amidostacks.com/web/stacks",
APPINSIGHTS_INSTRUMENTATIONKEY: $(APPINSIGHTS_INSTRUMENTATIONKEY)
MENU_API_URL: "https://dev-app.nonprod.amidostacks.com/web/stacks",
APPINSIGHTS_INSTRUMENTATIONKEY: $(app_insights_instrumentation_key)
}
build_out: './dist'
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ stages:
TF_VAR_name_component: $(domain),
TF_VAR_name_environment: nonprod,
TF_VAR_create_acr: true,
TF_VAR_acme_email: "[email protected]",
TF_VAR_is_cluster_private: true,
TF_VAR_cluster_version: $(aks_cluster_version),
TF_VAR_stage: nonprod,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ variables:

# Deployed app urls
- name: base_url
value: 'https://app.nonprod.amidostacks.com'
value: 'https://dev-app.nonprod.amidostacks.com'
- name: base_path
value: '/web/stacks'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,9 @@ variables:
docker_dockerfile_path: "src/"
docker_image_name: $(self_generic_name)
docker_image_tag: "$(version_major).$(version_minor).$(version_revision)-$(build.sourcebranchname)"
docker_container_registry_name: amidostacksnonproduksnode
docker_container_registry_name: amidostacksnonprodeuncore
k8s_docker_registry: $(docker_container_registry_name).azurecr.io
# AKS/AZURE
# Infra
conventional_resource_namer: $(company)-$(project)-nonprod-uks-$(domain)
base_domain: nonprod.amidostacks.com
base_domain_internal: nonprod.amidostacks.internal
# Dynamic vars for downstream purposes
Expand Down Expand Up @@ -139,15 +137,15 @@ stages:
# Should be hardcoded in your sonar-project.properties file
unit_test: true
project_root_dir: $(Agent.BuildDirectory)/s/$(self_repo)/$(self_repo_src)
cypress_e2e_test: true
cypress_applitools_test: true
cypress_e2e_test: false
cypress_applitools_test: false
cypress_container: cypress
# Set this to false or remove if cypress is not run as part of your pipeline
cache_cypress: true
cypress_e2e_env_vars:
PORT: 3000
APP_BASE_URL: "http://localhost"
MENU_API_URL: "https://api.demo.nonprod.amidostacks.com/api/menu"
MENU_API_URL: "https://dev-netcore-api.nonprod.amidostacks.com/api/menu"
APP_BASE_PATH: ""
NODE_ENV: development
# avoid warnings about terminal
Expand Down Expand Up @@ -203,18 +201,19 @@ stages:
tags: ''
# Terraform Resource Specific Config
terraform_extra_properties: {
TF_VAR_resource_group_location: uksouth,
TF_VAR_use_existing_resource_group: true,
TF_VAR_resource_group_name: amido-stacks-nonprod-uks-node,
TF_VAR_resource_group_location: northeurope,
TF_VAR_create_cdn_endpoint: false,
TF_VAR_create_dns_record: true,
TF_VAR_app_gateway_frontend_ip_name: "amido-stacks-nonprod-eun-core",
TF_VAR_app_insights_name: "amido-stacks-nonprod-eun-core",
TF_VAR_core_resource_group: "amido-stacks-nonprod-eun-core",
TF_VAR_name_company: $(company),
TF_VAR_name_project: $(project),
TF_VAR_name_component: $(component),
TF_VAR_name_domain: $(domain),
TF_VAR_create_cosmosdb: false,
TF_VAR_create_cache: true,
TF_VAR_name_environment: dev,
TF_VAR_name_stage: dev,
TF_VAR_app_gateway_frontend_ip_name: amido-stacks-nonprod-uks-node,
TF_VAR_dns_record: app,
TF_VAR_dns_record: dev-app,
TF_VAR_dns_zone_name: $(base_domain),
TF_VAR_internal_dns_zone_name: $(base_domain_internal)
}
Expand All @@ -229,6 +228,7 @@ stages:
variables:
redis_host: $[ dependencies.AppInfraDev.outputs['tfoutputs.redis_cache_hostname'] ]
redis_key: $[ dependencies.AppInfraDev.outputs['tfoutputs.redis_cache_key'] ]
app_insights_instrumentation_key: $[ dependencies.AppInfraDev.outputs['tfoutputs.app_insights_instrumentation_key'] ]
pool:
vmImage: ubuntu-18.04
environment: dev
Expand Down Expand Up @@ -259,23 +259,23 @@ stages:
base: $(Agent.BuildDirectory)/s/$(self_repo)/deploy/k8s/app/base_app-deploy.yml,
displayName: AppDeployment,
env_vars: {
dns_pointer: app.$(base_domain),
dns_pointer: dev-app.$(base_domain),
tls_domain: $(base_domain),
k8s_app_path: /web/stacks,
k8s_image: '$(k8s_docker_registry)/$(docker_image_name):$(docker_image_tag)',
api_url: 'https://api.demo.nonprod.amidostacks.com/api/menu',
api_url: 'https://dev-netcore-api.nonprod.amidostacks.com/api/menu',
app_name: webapp-template,
aadpodidentitybinding: stacks-webapp-identity,
app_insights_key: $(APPINSIGHTS_INSTRUMENTATIONKEY),
app_insights_key: $(app_insights_instrumentation_key),
next_public_token: $(NEXT_PUBLIC_CONTENTFUL_ACCESS_TOKEN),
next_space_id: $(NEXT_PUBLIC_CONTENTFUL_SPACE_ID),
auth_client_secret: $(AUTH0_CLIENT_SECRET),
auth_domain: $(AUTH0_DOMAIN),
auth_client_id: $(AUTH0_CLIENT_ID),
redis_host: $(redis_host),
redis_key: $(redis_key),
redis_port: "443",
redis_enabled: "false"
redis_port: "6380",
redis_enabled: "true"
},
args: "-no-empty",
}
Expand All @@ -287,8 +287,8 @@ stages:
scripts_dir: $(scripts_dir)
download_deploy_artefact: false
# Kubernetes Config
kubernetes_clusterrg: $(company)-$(project)-nonprod-uks-$(domain)
kubernetes_clustername: $(company)-$(project)-nonprod-uks-$(domain)
kubernetes_clusterrg: amido-stacks-nonprod-eun-core
kubernetes_clustername: amido-stacks-nonprod-eun-core
# Mutation Information
kubectl_filepath:
- $(Agent.BuildDirectory)/s/$(self_repo)/deploy/k8s/app/app-deploy.yml
Expand All @@ -305,8 +305,8 @@ stages:
- template: azDevOps/azure/templates/v2/steps/test-functional-testcafe.yml@templates
parameters:
env_vars:
APP_BASE_URL: "https://app.$(base_domain)"
MENU_API_URL: "http://api.demo.nonprod.amidostacks.com/api/menu"
APP_BASE_URL: "https://dev-app.$(base_domain)"
MENU_API_URL: "http://dev-netcore-api.nonprod.amidostacks.com/api/menu"
APP_BASE_PATH: "/web/stacks"
NODE_ENV: production
working_directory: $(Agent.BuildDirectory)/s/$(self_repo)/test/testcafe
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ stages:
cypress_e2e_env_vars:
PORT: 3000
APP_BASE_URL: "http://localhost"
MENU_API_URL: "https://api.demo.nonprod.amidostacks.com/api/menu"
MENU_API_URL: "https://dev-netcore-api.nonprod.amidostacks.com/api/menu"
APP_BASE_PATH: ""
NODE_ENV: dev
# avoid warnings about terminal
Expand Down Expand Up @@ -288,7 +288,7 @@ stages:
parameters:
env_vars:
APP_BASE_URL: "https://app.$(base_domain)"
MENU_API_URL: "http://api.demo.nonprod.amidostacks.com/api/menu"
MENU_API_URL: "http://dev-netcore-api.nonprod.amidostacks.com/api/menu"
APP_BASE_PATH: "/web/stacks"
NODE_ENV: production
working_directory: $(Agent.BuildDirectory)/s/$(self_repo)/test/testcafe
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ pipeline {
environment {
PORT="3000"
APP_BASE_URL="http://localhost"
MENU_API_URL="https://api.demo.nonprod.amidostacks.com/api/menu"
MENU_API_URL="https://dev-netcore-api.nonprod.amidostacks.com/api/menu"
APP_BASE_PATH=""
}
steps {
Expand Down
18 changes: 18 additions & 0 deletions packages/scaffolding-cli/templates/deploy/azure/app/csr/custom.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Example of further extensions to Stacks Core templates
# Potential user defined extensions
data "azurerm_application_insights" "example" {
name = var.app_insights_name
resource_group_name = var.core_resource_group
}

output "app_insights_instrumentation_key" {
description = "App Insights key for downstream deploymnent use"
value = data.azurerm_application_insights.example.instrumentation_key
sensitive = true
}

variable app_insights_name {
type = string
default = ""
description = "app insights name for key retriaval in memory"
}
18 changes: 18 additions & 0 deletions packages/scaffolding-cli/templates/deploy/azure/app/kube/custom.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Example of further extensions to Stacks Core templates
# Potential user defined extensions
data "azurerm_application_insights" "example" {
name = var.app_insights_name
resource_group_name = var.core_resource_group
}

output "app_insights_instrumentation_key" {
description = "App Insights key for downstream deploymnent use"
value = data.azurerm_application_insights.example.instrumentation_key
sensitive = true
}

variable app_insights_name {
type = string
default = ""
description = "app insights name for key retriaval in memory"
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# We are keeping this as a lookup
# since proper conventions for naming of resources should be followed
# since proper conventions for naming of resources should be followed
# and things can always be looked up without resorting to cross state searches
data "azurerm_public_ip" "app_gateway" {
name = var.app_gateway_frontend_ip_name
resource_group_name = var.resource_group_name
resource_group_name = var.core_resource_group
}
Loading

0 comments on commit db753f2

Please sign in to comment.