Skip to content

Commit

Permalink
Merge master
Browse files Browse the repository at this point in the history
  • Loading branch information
cp-sumi-k committed Feb 13, 2024
1 parent 6837b92 commit 3539ecc
Show file tree
Hide file tree
Showing 22 changed files with 2,006 additions and 1,887 deletions.
34 changes: 22 additions & 12 deletions .github/workflows/deploy-frontend-dev.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
name: DeployFrontendDev
name: DeployFrontendSSRLambdaDev

on:
workflow_run:
workflows: ["DeployBackendDev"]
types:
- completed
branches:
- "master"
push

jobs:
deploy-frontend-dev:
Expand All @@ -28,13 +23,28 @@ jobs:
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/github-actions-frontend-access
aws-region: ap-south-1

- name: Build frontend and copy to S3
- name: Build frontend and copy zip to S3
run: |
cd nuxt-frontend
sed -i "s|VITE_RECAPTCHA_SITE_KEY_VALUE|${{ secrets.RECAPTCHA_SITE_KEY }}|g" config.js
sed -i "s|RESOURCES_URL|${{ secrets.RESOURCES_URL }}|g" config.js
sed -i "s|CLOUDFRONT_URL_VALUE|${{ secrets.CLOUDFRONT_URL_VALUE_DEV }}|g" config.js
sh ./../deploy/generate-sitemap.sh https://dev-stack.canopas.com https://dev-stack-api.canopas.com
yarn install --frozen-lockfile && yarn generate
aws s3 sync ./.output/public s3://dev-stack.canopas.com --exclude "*.js"
aws s3 sync ./.output/public s3://dev-stack.canopas.com --include "*.js" --content-type "application/javascript"
aws cloudfront create-invalidation --distribution-id ${{ secrets.DEV_CLOUDFRONT_DISTRIBUTION_ID }} --paths "/*"
yarn install --frozen-lockfile && yarn build
aws s3 rm s3://canopas-website-ssr-dev --recursive
cd .output/server && zip canopas_website_SSR_dev_${{ github.sha }}-${{ github.run_attempt }}.zip -r . && aws s3 cp canopas_website_SSR_dev_${{ github.sha }}-${{ github.run_attempt }}.zip s3://canopas-lambda-handlers && cd ../..
aws s3 sync ./.output/public s3://canopas-website-ssr-dev --exclude "*.js"
aws s3 sync ./.output/public s3://canopas-website-ssr-dev --include "*.js" --content-type "application/javascript"
- name: Deploy cloudformation stack
id: canopas-website-dev-lambda-stack-frontend
uses: aws-actions/aws-cloudformation-github-deploy@v1
with:
name: canopas-website-dev-lambda-stack-frontend
template: infrastructure/frontend.yml
capabilities: CAPABILITY_IAM,CAPABILITY_NAMED_IAM, CAPABILITY_AUTO_EXPAND
timeout-in-minutes: "10"
no-fail-on-empty-changeset: "1"
parameter-overrides: >-
EnvName=dev,
ZipFileName=canopas_website_SSR_dev_${{ github.sha }}-${{ github.run_attempt }}.zip
27 changes: 21 additions & 6 deletions .github/workflows/deploy-frontend-prod.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: DeployFrontendProd
name: DeployFrontendSSRLambdaProd

on:
workflow_run:
Expand Down Expand Up @@ -28,14 +28,29 @@ jobs:
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/github-actions-frontend-access
aws-region: ap-south-1

- name: Build frontend and copy to S3
- name: Build frontend and copy zip to S3
run: |
cd nuxt-frontend
sed -i "s|VITE_RECAPTCHA_SITE_KEY_VALUE|${{ secrets.RECAPTCHA_SITE_KEY }}|g" config.prod.js
sed -i "s|RESOURCES_URL|${{ secrets.RESOURCES_URL }}|g" config.prod.js
sed -i "s|CLOUDFRONT_URL_VALUE|${{ secrets.CLOUDFRONT_URL_VALUE_PROD }}|g" config.prod.js
mv config.prod.js config.js
sh ./../deploy/generate-sitemap.sh https://canopas.com https://prod-stack-api.canopas.com
yarn install --frozen-lockfile && yarn generate
aws s3 sync ./.output/public s3://canopas.com --exclude "*.js"
aws s3 sync ./.output/public s3://canopas.com --include "*.js" --content-type "application/javascript"
aws cloudfront create-invalidation --distribution-id ${{ secrets.PROD_CLOUDFRONT_DISTRIBUTION_ID }} --paths "/*"
yarn install --frozen-lockfile && yarn build
aws s3 rm s3://canopas-website-ssr-prod --recursive
cd .output/server && zip canopas_website_SSR_prod_${{ github.sha }}-${{ github.run_attempt }}.zip -r . && aws s3 cp canopas_website_SSR_prod_${{ github.sha }}-${{ github.run_attempt }}.zip s3://canopas-lambda-handlers && cd ../..
aws s3 sync ./.output/public s3://canopas-website-ssr-prod --exclude "*.js"
aws s3 sync ./.output/public s3://canopas-website-ssr-prod --include "*.js" --content-type "application/javascript"
- name: Deploy cloudformation stack
id: canopas-website-prod-lambda-stack-frontend
uses: aws-actions/aws-cloudformation-github-deploy@v1
with:
name: canopas-website-prod-lambda-stack-frontend
template: infrastructure/frontend.yml
capabilities: CAPABILITY_IAM,CAPABILITY_NAMED_IAM, CAPABILITY_AUTO_EXPAND
timeout-in-minutes: "10"
no-fail-on-empty-changeset: "1"
parameter-overrides: >-
EnvName=prod,
ZipFileName=canopas_website_SSR_prod_${{ github.sha }}-${{ github.run_attempt }}.zip
112 changes: 42 additions & 70 deletions infrastructure/frontend.yml
Original file line number Diff line number Diff line change
@@ -1,82 +1,54 @@
AWSTemplateFormatVersion: 2010-09-09
Description: An ECS with launchType EC2 frontend stack
AWSTemplateFormatVersion: "2010-09-09"
Transform:
- AWS::LanguageExtensions
- AWS::Serverless-2016-10-31

Description: Canopas website microservices using AWS Lambda.

Parameters:
EnvName:
Type: String
Description: Name of an environment. 'dev', 'staging', 'prod' and any name.
Description: Name of an environment.
AllowedPattern: ^.*[^0-9]$
ConstraintDescription: Must end with non-numeric character.
ClusterName:
Type: String
Description: Name of ECS cluster
ImageTag:
Type: String
Description: Website Docker frontend image tag
NginxImageTag:
AllowedValues:
- dev
- prod
ZipFileName:
Type: String
Description: NGINX Docker image tag
BlogImageTag:
Type: String
Description: Blog Docker image tag
Description: Name of the zip file.

Resources:
TaskDefinition:
Type: AWS::ECS::TaskDefinition
HttpApi:
Type: AWS::Serverless::HttpApi
Properties:
Family:
Fn::Sub: canopas-website-${EnvName}-full-stack-task-definition
ExecutionRoleArn:
Fn::Sub: arn:aws:iam::${AWS::AccountId}:role/ecsTaskExecutionRole
NetworkMode: "bridge"
ContainerDefinitions:
- Name: "canopas-website-nginx"
Hostname: "canopas-website-nginx"
Memory: 128
Cpu: 128
Essential: true
Image:
Fn::Sub: ${AWS::AccountId}.dkr.ecr.${AWS::Region}.amazonaws.com/canopas-website-nginx:${NginxImageTag}
PortMappings:
- ContainerPort: 80
HostPort: 80
Protocol: tcp
Links:
- canopas-website-frontend
- canopas-blog

- Name: "canopas-website-frontend"
Memory: 256
Cpu: 256
Essential: true
Image:
Fn::Sub: ${AWS::AccountId}.dkr.ecr.${AWS::Region}.amazonaws.com/canopas-website-frontend:${ImageTag}
PortMappings:
- ContainerPort: 3080
HostPort: 3080
Protocol: tcp

- Name: "canopas-blog"
Memory: 256
Cpu: 256
Essential: true
Image:
Fn::Sub: ${AWS::AccountId}.dkr.ecr.${AWS::Region}.amazonaws.com/canopas-blog:${BlogImageTag}
PortMappings:
- ContainerPort: 3000
HostPort: 3000
Protocol: tcp
StageName: $default
Name:
Fn::Sub: canopas-website-ssr-frontend-${EnvName}
Description:
Fn::Sub: Canopas Website SSR Frontend API ${EnvName}

ECSService:
Type: AWS::ECS::Service
HttpApiFunction:
Type: AWS::Serverless::Function
Properties:
ServiceName: "canopas-website-full-stack"
LaunchType: EC2
Cluster:
Fn::Sub: ${ClusterName}
DesiredCount: 1
TaskDefinition:
Ref: "TaskDefinition"
DeploymentConfiguration:
MaximumPercent: 100
MinimumHealthyPercent: 0
PackageType: Zip
CodeUri:
Fn::Sub: s3://canopas-lambda-handlers/${ZipFileName}
Handler: index.handler
Runtime: nodejs20.x
Architectures:
- x86_64
MemorySize: 256
Timeout: 30
FunctionName:
Fn::Sub: canopas-website-ssr-frontend-${EnvName}
Description:
Fn::Sub: Canopas Website SSR Frontend Lambda ${EnvName}
Events:
ProxyResource:
Type: HttpApi
Properties:
ApiId:
Ref: HttpApi
Path: $default
Method: any
86 changes: 75 additions & 11 deletions nuxt-frontend/assets/css/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,87 +3,151 @@
font-family: Product Sans;
font-style: normal;
font-weight: 400;
src: url(../fonts/ProductSans-Regular-Subset.woff2) format("woff2");
src: url(~/assets/fonts/ProductSans-Regular-Subset.woff2) format("woff2");
}

@font-face {
font-display: swap;
font-family: FuturaLT-Bold;
font-style: bold;
font-weight: 700;
src: url(../fonts/FuturaLT-Bold-Subset.woff2);
src: url(~/assets/fonts/FuturaLT-Bold-Subset.woff2) format("woff2");
}

@font-face {
font-display: swap;
font-family: Inter-Bold;
font-style: bold;
font-weight: 700;
src: url(../fonts/Inter-Bold-Subset.woff2) format("woff2");
src: url(~/assets/fonts/Inter-Bold-Subset.woff2) format("woff2");
}

@font-face {
font-display: swap;
font-family: Inter-SemiBold;
font-style: normal;
font-weight: 600;
src: url(../fonts/Inter-SemiBold-Subset.woff2) format("woff2");
src: url(~/assets/fonts/Inter-SemiBold-Subset.woff2) format("woff2");
}

@font-face {
font-display: swap;
font-family: Inter-Medium;
font-style: medium;
font-weight: 500;
src: url(../fonts/Inter-Medium-Subset.woff2) format("woff2");
src: url(~/assets/fonts/Inter-Medium-Subset.woff2) format("woff2");
}

@font-face {
font-display: swap;
font-family: Inter-Regular;
font-style: normal;
font-weight: 400;
src: url(../fonts/Inter-Regular-Subset.woff2) format("woff2");
src: url(~/assets/fonts/Inter-Regular-Subset.woff2) format("woff2");
}

@font-face {
font-display: swap;
font-family: Inter-Light;
font-style: normal;
font-weight: 300;
src: url(../fonts/Inter-Light-Subset.woff2) format("woff2");
src: url(~/assets/fonts/Inter-Light-Subset.woff2) format("woff2");
}

@font-face {
font-display: swap;
font-family: Roboto-Bold;
font-style: normal;
font-weight: 600;
src: url(../fonts/Roboto-Bold-Subset.woff2);
src: url(~/assets/fonts/Roboto-Bold-Subset.woff2) format("woff2");
}

@font-face {
font-display: swap;
font-family: Roboto-Medium;
font-style: normal;
font-weight: 500;
src: url(../fonts/Roboto-Medium-Subset.woff2);
src: url(~/assets/fonts/Roboto-Medium-Subset.woff2) format("woff2");
}

@font-face {
font-display: swap;
font-family: Opensans-Bold;
font-style: bold;
font-weight: 700;
src: url(../fonts/Open-Sans-Bold.woff2) format("woff2");
src: url(~/assets/fonts/Open-Sans-Bold.woff2) format("woff2");
}

@font-face {
font-display: swap;
font-family: Opensans-SemiBold;
font-style: normal;
font-weight: 600;
src: url(../fonts/Open-Sans-SemiBold.woff2) format("woff2");
src: url(~/assets/fonts/Open-Sans-SemiBold.woff2) format("woff2");
}

@font-face {
font-display: swap;
font-family: Source CodePro;
font-style: normal;
font-weight: 400;
src: url(~/assets/fonts/Source-codePro.woff2) format("woff2");
}

@font-face {
font-display: swap;
font-family: Poppins Regular;
font-style: normal;
font-weight: 400;
src: url(~/assets/fonts/Poppins-Regular.woff2) format("woff2");
}

@font-face {
font-display: swap;
font-family: Poppins Medium;
font-style: medium;
font-weight: 500;
src: url(~/assets/fonts/Poppins-Medium.woff2) format("woff2");
}

@font-face {
font-display: swap;
font-family: Inter-ExtraLight;
font-style: normal;
font-weight: 200;
src: url(~/assets/fonts/Inter-ExtraLight.woff2) format("woff2");
}

@font-face {
font-display: swap;
font-family: Comme-Light;
font-style: normal;
font-weight: 300;
src: url(~/assets/fonts/Comme-Light.woff2) format("woff2");
}

@font-face {
font-display: swap;
font-family: Comme-Regular;
font-style: normal;
font-weight: 400;
src: url(~/assets/fonts/Comme-Regular.woff2) format("woff2");
}

@font-face {
font-display: swap;
font-family: Comme-Medium;
font-style: normal;
font-weight: 500;
src: url(~/assets/fonts/Comme-Medium.woff2) format("woff2");
}

@font-face {
font-display: swap;
font-family: Comme-SemiBold;
font-style: normal;
font-weight: 600;
src: url(~/assets/fonts/Comme-SemiBold.woff2) format("woff2");
}

@font-face {
Expand Down
Loading

0 comments on commit 3539ecc

Please sign in to comment.