Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Er 861 hfeyp staging #661

Merged
merged 16 commits into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions .github/workflows/azure-deploy-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ env:
ARM_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
ARM_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
DOCKER_IMAGE: ghcr.io/dfe-digital/help-for-early-years-providers
RELEASE_VERSION: ${{ github.sha }}

jobs:
build-and-deploy:
Expand Down Expand Up @@ -69,7 +70,7 @@ jobs:
build-args: BUILDKIT_INLINE_CACHE=1
cache-from: |
${{ env.DOCKER_IMAGE }}-dev:builder
push: true
push: true
tags: ${{ env.DOCKER_IMAGE }}-dev:builder
target: builder

Expand All @@ -81,7 +82,7 @@ jobs:
build-args: BUILDKIT_INLINE_CACHE=1
cache-from: |
${{ env.DOCKER_IMAGE }}-dev:gems-node-modules
push: true
push: true
tags: ${{ env.DOCKER_IMAGE }}-dev:gems-node-modules
target: help-for-early-years-providers-gems-node-modules

Expand All @@ -93,7 +94,7 @@ jobs:
build-args: BUILDKIT_INLINE_CACHE=1
cache-from: |
${{ env.DOCKER_IMAGE }}-dev:assets-precompile
push: true
push: true
tags: ${{ env.DOCKER_IMAGE }}-dev:assets-precompile
target: assets-precompile

Expand Down Expand Up @@ -126,4 +127,4 @@ jobs:
uses: azure/webapps-deploy@v2
with:
app-name: ${{ vars.WEBAPP_NAME }}
images: ${{ env.DOCKER_IMAGE }}:${{ github.sha }}
images: ${{ env.DOCKER_IMAGE }}:${{ github.sha }}
92 changes: 92 additions & 0 deletions .github/workflows/azure-deploy-stage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
name: 'HfEYP App Deploy [Azure - STAGE]'

on:
workflow_dispatch:
inputs:
candidate:
description: 'Create release candidate version ("rcx.x.x")'
type: string
required: true
ref:
description: 'Git ref or branch to deploy'
type: string
required: true
default: main

# Permissions for OIDC authentication
permissions:
id-token: write
contents: write
packages: write

env:
ARM_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
ARM_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
ARM_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
DOCKER_IMAGE: ghcr.io/dfe-digital/help-for-early-years-providers
RELEASE_VERSION: ${{ inputs.candidate || github.sha }}

jobs:
build-and-deploy:
runs-on: ubuntu-latest
environment: staging
steps:
# Checkout the repository to the GitHub Actions runner
- name: Checkout Code
uses: actions/checkout@v4
with:
ref: ${{ inputs.ref || github.ref_name }}

# Tag the branch with the release candidate version
- name: Tag candidate
if: ${{ inputs.candidate }}
run: |
git tag --force ${{ inputs.candidate }}
git push --force origin refs/tags/${{ inputs.candidate }}
echo "HEAD=$(git rev-parse ${{ inputs.candidate }})" >> $GITHUB_ENV

# Create and boot Docker image builder
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
version: v0.9.1

# Login to Github Container Registry
- name: Login to Github Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

# Build and push image
- name: Build and push Docker Image
uses: docker/build-push-action@v5
with:
target: production
context: .
file: Dockerfile.azure
build-args: |
BUILDKIT_INLINE_CACHE=1
SHA=${{ github.sha }}
cache-from: |
${{ env.DOCKER_IMAGE }}:${{ github.sha }}
${{ env.DOCKER_IMAGE }}:${{ inputs.ref || github.ref_name }}
tags: |
${{ env.DOCKER_IMAGE }}:${{ github.sha }}
${{ env.DOCKER_IMAGE }}:${{ inputs.candidate || github.ref_name }}

# Login to Azure using OIDC
- name: Login to Azure CLI
uses: azure/login@v1
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}

# Deploy Web Application
- name: Deploy to Azure App Services
uses: azure/webapps-deploy@v2
with:
app-name: ${{ vars.WEBAPP_NAME }}
images: ${{ env.DOCKER_IMAGE }}:${{ inputs.candidate || github.ref_name }}
2 changes: 1 addition & 1 deletion config/credentials/production.yml.enc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
MNHimzHKDFqAUc9oJSgl6ulO+sw2H7QjpmpfcBj0JvHlP9DTGj2ZW0EYRCJrcgvA/+84UUWTK3ueNLQBR9/eJtTDYrL2RDI3STFtZdbMYkCvDJCpx8kGvCoTjpKRKt+3S4tKmDQfCrDmjywQw+gRbjL6fUCy5w5mh3qDbpuvUXFYfeu1Ck0Zx9IZJ9Q6WsbL3D0TuHQftpfCnZHjmkCbJkXLgk3hOttbtYMXtvyzpSgc8S2XVHsqCPhEtk7oQueyPSpNE40wBEXzGLMaj7Yy9hLHKUI2ZJd0SK0WmnQexP6hguvAT5upHeKLF5VXzDmkybdi3qDzn4zy5Q7VYum5K3OcrMlOoiY2meuYy8uSkIrtUJ9xTdiqel0Fk+QoPSE954FQRe9RFWBRhD3DNeCkbCimaKF2lCbiE7X6Kd+Gr/c33MGH8/Q+Nv72vUHVB2QqT0xyKmkFKqNgaeSVqTaH//Ii6fYmP3CaORNi/rOeiB2edX16bQn/gL8qQWuHg38J0ojR9cFRtmm76Jv6Ped9CYQSRsrGwz3wFn2WKMq+QR5+zTIXXnyItPEmbMwCzwhkagW60HyeONG78QLmKz34uYVvCGPPgLeDCOXMNy8hyVkNcThEZWBH6nlRXfPrj4HgVzZkg9snl8bkds0izLPNppJJNCjAy+m6Lbr7QJDf8g0UtNjkscaOP3e5ahw/Ihk8maMq20L5oq6xuTm4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bVISdl2KapIb+/el7z9+4Xa4FEfKluvhVWsWEunUZjUqsy4xWTPBrnOgHBEW4v3Hsz8aEYq51PwyT6FQCCFwovcNcTWHm+UzYBLPyTwH4EFm0gErdgp5QKvT1vVu1WfHajLh/8sLVJYNmYc8uY8fUvSaYpNNvFJbv0KxR0FMo60LBt4hihRBYivfdADm5OSMZn/FBHgDec0A5wwxSWQHe3EgSAxwuoAqQNDjRg6p5xsO6pBgo+RxZKRbLnwt8ZJRvwKnnh3enQFQXrecYMG4BMnVup1qQVJDwufK8lFvp7n/AzCzguyHjJiY2HWYfcVK8cXRMhIirW/CRlJOqS2+6YZlEVr8t/nTkMFIWm6VaYJL+XT/q4IBypNfR1NyUPrIi--q/wx5B6nVwp4CgHK--rScnJ5MUq8ZWzfxsLa0Z2A==
1 change: 1 addition & 0 deletions config/initializers/content_security_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
policy.font_src :self, :https, *GOVUK_DOMAINS, *GOOGLE_STATIC_DOMAINS, :data
policy.frame_src :self, *GOOGLE_ANALYTICS_DOMAINS, *OPTIMIZE_DOMAINS
policy.img_src :self,
"images.ctfassets.net",
*GOVUK_DOMAINS,
*S3_DOMAINS,
*GOOGLE_ANALYTICS_DOMAINS, # Tracking pixels
Expand Down
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Rails.application.routes.draw do
get "/check" => "application#check"
get "/health" => "application#check"

# Note These have to be above the wildcard route
get "/404", to: "errors#not_found", via: :all
Expand Down
2 changes: 2 additions & 0 deletions entrypoints/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ fi

/usr/sbin/sshd

eval $(printenv | sed -n "s/^\([^=]\+\)=\(.*\)$/export \1=\2/p" | sed 's/"/\\\"/g' | sed '/=/s//="/' | sed 's/$/"/' >> /etc/profile)

bundle exec rake db:prepare db:seed

# Start the application
Expand Down
2 changes: 1 addition & 1 deletion terraform-azure/terraform-azure-database/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,4 @@ resource "azurerm_postgresql_flexible_server_database" "psqldb_slot" {
server_id = azurerm_postgresql_flexible_server.psqlfs.id
collation = "en_US.utf8"
charset = "utf8"
}
}
2 changes: 2 additions & 0 deletions terraform-azure/terraform-azure-remote-state/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ resource "azurerm_storage_account" "tfstate" {
#checkov:skip=CKV2_AZURE_1:Microsoft Managed keys are sufficient
#checkov:skip=CKV2_AZURE_38:Soft-delete not required
#checkov:skip=CKV2_AZURE_33:VNet not configured
#checkov:skip=CKV2_AZURE_41:Ensure storage account is configured with SAS expiration policy
#checkov:skip=CKV2_AZURE_40:Ensure storage account is not configured with Shared Key authorization
}

resource "azurerm_storage_container" "tfstate" {
Expand Down
3 changes: 2 additions & 1 deletion terraform-azure/terraform-azure-web/webapp.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ resource "azurerm_service_plan" "asp" {
}

#checkov:skip=CKV_AZURE_212:Argument not available
#checkov:skip=CKV_AZURE_225:Ensure the App Service Plan is zone redundant
}

# Create Web Application
Expand Down Expand Up @@ -354,4 +355,4 @@ resource "azurerm_app_service_certificate_binding" "webapp_custom_domain_cert_bi
hostname_binding_id = azurerm_app_service_custom_hostname_binding.webapp_custom_domain[0].id
certificate_id = azurerm_app_service_certificate.webapp_custom_domain_cert[0].id
ssl_state = "SniEnabled"
}
}
4 changes: 2 additions & 2 deletions terraform-azure/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ variable "azure_region" {
}

variable "environment" {
default = "development"
default = "staging"
description = "Environment to deploy resources"
type = string
}

variable "resource_name_prefix" {
default = "s195d01-hfeyp"
default = "s195t01-hfeyp"
description = "Prefix for resource names"
type = string
}
Expand Down
Loading