-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #188 from DFE-Digital/760-technical-guidance-migra…
…tion 760 technical guidance migration
- Loading branch information
Showing
21 changed files
with
449 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
name: Delete review app on AKS | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- master | ||
types: | ||
- closed | ||
|
||
concurrency: deploy-${{ github.ref }} | ||
|
||
jobs: | ||
build-and-push: | ||
runs-on: ubuntu-latest | ||
environment: review | ||
|
||
steps: | ||
- name: Destroy review app | ||
uses: actions/checkout@v4 | ||
|
||
- uses: hashicorp/setup-terraform@v3 | ||
with: | ||
terraform_version: 1.6.4 | ||
terraform_wrapper: false | ||
|
||
- uses: DFE-Digital/github-actions/set-arm-environment-variables@master | ||
with: | ||
azure-credentials: ${{ secrets.AZURE_CREDENTIALS }} | ||
|
||
- name: Terraform Destroy | ||
run: | | ||
make ci review terraform-destroy | ||
env: | ||
PR_NUMBER: ${{ github.event.pull_request.number }} | ||
|
||
- name: Post Pull Request Comment | ||
if: ${{ github.event_name == 'pull_request' }} | ||
uses: marocchino/sticky-pull-request-comment@v2 | ||
with: | ||
header: aks | ||
message: Review app <https://technical-guidance-${{ github.event.pull_request.number }}.test.teacherservices.cloud> was deleted |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
name: Build and deploy to AKS cluster | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
branches: | ||
- master | ||
|
||
concurrency: deploy-${{ github.ref }} | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
docker-image-tag: ${{ steps.build-image.outputs.tag }} | ||
matrix-environments: ${{ toJSON(steps.*.outputs.matrix-environment) }} | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup ruby | ||
uses: ruby/setup-ruby@v1 | ||
with: | ||
ruby-version: 2.7 | ||
bundler-cache: true | ||
|
||
- name: Build docs with middleman | ||
run: make build | ||
|
||
- name: Build and push docker image | ||
id: build-image | ||
uses: DFE-Digital/github-actions/build-docker-image@master | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
context: . | ||
|
||
- name: Prepare matrix environments review | ||
id: matrix-env-review | ||
if: github.event_name == 'pull_request' | ||
run: echo "matrix-environment=review" >> $GITHUB_OUTPUT | ||
|
||
- name: Prepare matrix environments for production | ||
id: matrix-env-main | ||
if: github.ref == 'refs/heads/main' && github.event_name == 'push' | ||
run: | | ||
echo "matrix-environment=production" >> $GITHUB_OUTPUT | ||
deploy: | ||
name: Deploy ${{ matrix.environment }} | ||
runs-on: ubuntu-latest | ||
needs: [build] | ||
environment: | ||
name: ${{ matrix.environment }} | ||
url: ${{ steps.get-app-url.outputs.url }} | ||
strategy: | ||
max-parallel: 1 | ||
matrix: | ||
environment: ${{ fromJSON(needs.build.outputs.matrix-environments) }} | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- uses: hashicorp/setup-terraform@v3 | ||
with: | ||
terraform_version: 1.6.4 | ||
terraform_wrapper: false | ||
|
||
- uses: DFE-Digital/github-actions/set-arm-environment-variables@master | ||
with: | ||
azure-credentials: ${{ secrets.AZURE_CREDENTIALS }} | ||
|
||
- name: Terraform Apply | ||
run: | | ||
make ci ${{ matrix.environment }} terraform-apply | ||
env: | ||
DOCKER_IMAGE_TAG: ${{ needs.build.outputs.docker-image-tag }} | ||
PR_NUMBER: ${{ github.event.pull_request.number }} | ||
|
||
- name: Get application URL | ||
id: get-app-url | ||
run: | | ||
url=$(terraform -chdir=terraform/application output -raw url) | ||
echo "url=${url}" >> $GITHUB_OUTPUT | ||
- name: Post comment to Pull Request ${{ github.event.number }} | ||
if: ${{ github.event_name == 'pull_request' }} | ||
uses: marocchino/sticky-pull-request-comment@v2 | ||
with: | ||
header: aks | ||
message: Review app deployed to <${{ steps.get-app-url.outputs.url }}> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
ruby 2.7.6 | ||
terraform 1.6.4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,3 @@ | ||
# Use the official Ruby 2.7.6 image as the base image | ||
FROM ruby:2.7.6 | ||
FROM nginx:1.25.3-alpine3.18-slim | ||
|
||
# Install Node.js and npm | ||
RUN apt-get update && apt-get install -y nodejs npm | ||
|
||
# RUN apt-get install -y nodejs npm | ||
|
||
# Set the working directory to /app | ||
WORKDIR /app | ||
|
||
# Copy the Gemfile and Gemfile.lock into the container | ||
COPY Gemfile Gemfile.lock ./ | ||
|
||
# Install the required gems | ||
RUN bundle install | ||
|
||
# Copy the package.json and package-lock.json into the container | ||
COPY package*.json ./ | ||
|
||
# Install the required npm packages | ||
RUN npm install | ||
|
||
# Copy the rest of the application code into the container | ||
COPY . . | ||
|
||
EXPOSE 4567 | ||
|
||
# Start the application | ||
CMD ["rails", "server", "-b", "0.0.0.0"] | ||
COPY ./build/ /usr/share/nginx/html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
CONFIG=production | ||
ENVIRONMENT=production | ||
CONFIG_SHORT=pd | ||
AZURE_SUBSCRIPTION=s189-teacher-services-cloud-production | ||
AZURE_RESOURCE_PREFIX=s189p01 | ||
ENABLE_KV_DIAGNOSTICS=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
CONFIG=review | ||
CONFIG_SHORT=rv | ||
AZURE_SUBSCRIPTION=s189-teacher-services-cloud-test | ||
AZURE_RESOURCE_PREFIX=s189t01 | ||
KV_PURGE_PROTECTION=false |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
module "application_configuration" { | ||
source = "./vendor/modules/aks//aks/application_configuration" | ||
|
||
namespace = var.namespace | ||
environment = var.environment | ||
azure_resource_prefix = var.azure_resource_prefix | ||
service_short = var.service_short | ||
config_short = var.config_short | ||
secret_key_vault_short = "app" | ||
|
||
# Delete for non rails apps | ||
is_rails_application = true | ||
|
||
config_variables = { | ||
ENVIRONMENT_NAME = var.environment | ||
} | ||
|
||
} | ||
|
||
module "web_application" { | ||
source = "./vendor/modules/aks//aks/application" | ||
|
||
is_web = true | ||
|
||
namespace = var.namespace | ||
environment = var.environment | ||
service_name = var.service_name | ||
|
||
cluster_configuration_map = module.cluster_data.configuration_map | ||
kubernetes_config_map_name = module.application_configuration.kubernetes_config_map_name | ||
kubernetes_secret_name = module.application_configuration.kubernetes_secret_name | ||
web_port = 80 | ||
probe_path = "/" | ||
|
||
docker_image = var.docker_image | ||
} |
Oops, something went wrong.