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

Refactor Buildspec files #5984

Merged
merged 1 commit into from
Nov 15, 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
19 changes: 19 additions & 0 deletions buildspec/build/build-frontend-preprod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
version: 0.2

env:
variables:
NODE_OPTIONS: "--max_old_space_size=8192"

phases:
install:
runtime-versions:
nodejs: 18
build:
commands:
- echo $CODEBUILD_RESOLVED_SOURCE_VERSION > commit_hash.txt
- cd frontend && npm ci
- npm run build:preprod

artifacts:
files:
- '**/*'
19 changes: 19 additions & 0 deletions buildspec/build/build-frontend-prod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
version: 0.2

env:
variables:
NODE_OPTIONS: "--max_old_space_size=8192"

phases:
install:
runtime-versions:
nodejs: 18
build:
commands:
- echo $CODEBUILD_RESOLVED_SOURCE_VERSION > commit_hash.txt
- cd frontend && npm ci
- npm run build:prod

artifacts:
files:
- '**/*'
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ phases:
- echo Building the Docker image...
- cd backend
- docker build -t $REPOSITORY_URI:$IMAGE_TAG -t $REPOSITORY_URI:latest .

post_build:
commands:
- echo Build completed on `date`
- echo Pushing the Docker images...
- docker push $REPOSITORY_URI:$IMAGE_TAG
- docker push $REPOSITORY_URI:latest

11 changes: 11 additions & 0 deletions buildspec/build/deploy-frontend-preprod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: 0.2

phases:
build:
commands:
- COMMIT_HASH=$(cat commit_hash.txt | cut -c 1-7)
- echo $COMMIT_HASH
- cd frontend/dist
- aws s3 cp --recursive . s3://sfc-frontend-build-artifacts/$COMMIT_HASH/preprod


Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,8 @@ phases:
build:
commands:
- COMMIT_HASH=$(cat commit_hash.txt | cut -c 1-7)
- echo $COMMIT_HASH
- cd frontend/dist
- aws s3 cp --recursive . s3://sfc-frontend-build-artifacts/$COMMIT_HASH
- aws s3 cp --recursive . s3://sfc-frontend-build-artifacts/$COMMIT_HASH/prod


11 changes: 11 additions & 0 deletions buildspec/build/deploy-frontend-staging.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: 0.2

phases:
build:
commands:
- COMMIT_HASH=$(cat commit_hash.txt | cut -c 1-7)
- echo $COMMIT_HASH
- cd frontend/dist
- aws s3 cp --recursive . s3://sfc-frontend-build-artifacts/$COMMIT_HASH/staging


File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,7 @@ phases:
- apt-get --assume-yes install ca-certificates fonts-liberation libasound2 libatk-bridge2.0-0 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgbm1 libgcc1 libglib2.0-0 libgtk-3-0 libnspr4 libnss3 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 lsb-release wget xdg-utils
build:
commands:
- cd frontend
- cd frontend
- npm run test-headless; EXITCODE=$?


17 changes: 17 additions & 0 deletions buildspec/build/test-performance.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
version: 0.2

phases:
install:
runtime-versions:
nodejs: 18
commands:
- curl -sS -o - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
- echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list
- apt-get -y update
- apt-get -y install google-chrome-stable
build:
commands:
- cd frontend
- npm install -g @lhci/[email protected]
- npm run build
- lhci autorun
21 changes: 21 additions & 0 deletions buildspec/deploy/deploy-benchmark.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
version: 0.2

phases:
pre_build:
commands:
- echo Logging in to Amazon ECR...
- aws --version
- aws ecr get-login-password --region eu-west-1 | docker login --username AWS --password-stdin 636146736465.dkr.ecr.eu-west-1.amazonaws.com
- export manifest=$(aws ecr batch-get-image --repository-name sfc-backend-build-images --image-ids imageTag=preprod --output text --query 'images[].imageManifest')

build:
commands:
- COMMIT_HASH=$(aws ecr describe-images --repository-name sfc-backend-build-images --image-ids imageTag=preprod --output text | awk '{print $2}' | grep -Ev 'latest|staging|preprod|prod|benchmark'| tail -n1)
- echo Retagging the latest ecr image...
- aws ecr batch-delete-image --repository-name sfc-backend-build-images --image-ids imageTag=benchmark
- aws ecr put-image --repository-name sfc-backend-build-images --image-tag benchmark --image-manifest "$manifest"
- echo Copy s3 bucket from bnd to benchmark...
# This will be uncommented when we generate frontend assets for benchmark
# - aws s3 cp --recursive s3://sfc-frontend-build-artifacts/$COMMIT_HASH/benchmark s3://sfc-frontend-benchmark/
- export $(printf "AWS_ACCESS_KEY_ID=%s AWS_SECRET_ACCESS_KEY=%s AWS_SESSION_TOKEN=%s" $(aws sts assume-role --role-arn arn:aws:iam::702856547275:role/CodebuildApprunnerCrossAccountAccessRole --role-session-name MySessionName --query "Credentials.[AccessKeyId,SecretAccessKey,SessionToken]" --output text))
- aws apprunner start-deployment --service-arn arn:aws:apprunner:eu-west-1:702856547275:service/sfc-app-runner-benchmark/147f2ec134464e94baca5c7864f92e2e
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ phases:

build:
commands:
- COMMIT_HASH=$(aws ecr describe-images --repository-name sfc-backend-build-images --image-ids imageTag=staging --output text | awk '{print $2}' | tail -n1)
- COMMIT_HASH=$(aws ecr describe-images --repository-name sfc-backend-build-images --image-ids imageTag=staging --output text | awk '{print $2}' | grep -Ev 'latest|staging|preprod|prod|benchmark'| tail -n1)
- echo Retagging the latest ecr image...
- aws ecr batch-delete-image --repository-name sfc-backend-build-images --image-ids imageTag=preprod
- aws ecr put-image --repository-name sfc-backend-build-images --image-tag preprod --image-manifest "$manifest"
- echo Copy s3 bucket from bnd to staging...
- aws s3 cp --recursive s3://sfc-frontend-build-artifacts/$COMMIT_HASH s3://sfc-frontend-preprod/
- echo Copy s3 bucket from bnd to preprod...
- aws s3 cp --recursive s3://sfc-frontend-build-artifacts/$COMMIT_HASH/preprod s3://sfc-frontend-preprod/
- export $(printf "AWS_ACCESS_KEY_ID=%s AWS_SECRET_ACCESS_KEY=%s AWS_SESSION_TOKEN=%s" $(aws sts assume-role --role-arn arn:aws:iam::114055388985:role/CodebuildApprunnerCrossAccountAccessRole --role-session-name MySessionName --query "Credentials.[AccessKeyId,SecretAccessKey,SessionToken]" --output text))
- aws apprunner start-deployment --service-arn arn:aws:apprunner:eu-west-1:114055388985:service/sfc-app-runner-preprod/5738485b160d41f688e33c69b5204670
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ phases:

build:
commands:
- COMMIT_HASH=$(aws ecr describe-images --repository-name sfc-backend-build-images --image-ids imageTag=preprod --output text | awk '{print $2}' | tail -n1)
- COMMIT_HASH=$(aws ecr describe-images --repository-name sfc-backend-build-images --image-ids imageTag=preprod --output text | awk '{print $2}' | grep -Ev 'latest|staging|preprod|prod|benchmark'| tail -n1)
- echo Retagging the latest ecr image...
- aws ecr batch-delete-image --repository-name sfc-backend-build-images --image-ids imageTag=prod
- aws ecr put-image --repository-name sfc-backend-build-images --image-tag prod --image-manifest "$manifest"
- echo Copy s3 bucket from bnd to staging...
- aws s3 cp --recursive s3://sfc-frontend-build-artifacts/$COMMIT_HASH s3://sfc-frontend-prod/
- echo Copy s3 bucket from bnd to prod...
- aws s3 cp --recursive s3://sfc-frontend-build-artifacts/$COMMIT_HASH/prod s3://sfc-frontend-prod/
- export $(printf "AWS_ACCESS_KEY_ID=%s AWS_SECRET_ACCESS_KEY=%s AWS_SESSION_TOKEN=%s" $(aws sts assume-role --role-arn arn:aws:iam::008366934221:role/CodebuildApprunnerCrossAccountAccessRole --role-session-name MySessionName --query "Credentials.[AccessKeyId,SecretAccessKey,SessionToken]" --output text))
- aws apprunner start-deployment --service-arn arn:aws:apprunner:eu-west-1:008366934221:service/sfc-app-runner-prod/52469c58deb84143ab8404f7ca69ccb6
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ phases:

build:
commands:
- COMMIT_HASH=$(aws ecr describe-images --repository-name sfc-backend-build-images --image-ids imageTag=latest --output text | awk '{print $2}' | tail -n1)
- COMMIT_HASH=$(aws ecr describe-images --repository-name sfc-backend-build-images --image-ids imageTag=latest --output text | awk '{print $2}' | grep -Ev 'latest|staging|preprod|prod|benchmark'| tail -n1)
- echo Retagging the latest ecr image...
- aws ecr batch-delete-image --repository-name sfc-backend-build-images --image-ids imageTag=staging
- aws ecr put-image --repository-name sfc-backend-build-images --image-tag staging --image-manifest "$manifest"
- echo Copy s3 bucket from bnd to staging...
- aws s3 cp --recursive s3://sfc-frontend-build-artifacts/$COMMIT_HASH s3://sfc-frontend-staging/
- aws s3 cp --recursive s3://sfc-frontend-build-artifacts/$COMMIT_HASH/staging s3://sfc-frontend-staging/
- export $(printf "AWS_ACCESS_KEY_ID=%s AWS_SECRET_ACCESS_KEY=%s AWS_SESSION_TOKEN=%s" $(aws sts assume-role --role-arn arn:aws:iam::101248264786:role/CodebuildApprunnerCrossAccountAccessRole --role-session-name MySessionName --query "Credentials.[AccessKeyId,SecretAccessKey,SessionToken]" --output text))
- aws apprunner start-deployment --service-arn arn:aws:apprunner:eu-west-1:101248264786:service/sfc-app-runner-staging/9e440da7842b4153bd211b2ca2645353
- aws apprunner start-deployment --service-arn arn:aws:apprunner:eu-west-1:101248264786:service/sfc-app-runner-staging/9e440da7842b4153bd211b2ca2645353
17 changes: 0 additions & 17 deletions buildspec/test-performance.yml

This file was deleted.

Loading