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

Rbni 42 fix #29

Merged
merged 14 commits into from
Oct 18, 2024
11 changes: 6 additions & 5 deletions .github/workflows/cicd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Configure aws credentials
uses: aws-actions/configure-aws-credentials@v2
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::654654270781:role/github-actions
aws-region: ${{ env.AWS_REGION }}
Expand Down Expand Up @@ -59,10 +59,10 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::654654270781:role/github-actions
aws-region: ${{ env.AWS_REGION }}
Expand All @@ -73,7 +73,8 @@ jobs:
SHA="${{ needs.build.outputs.commit_sha }}"
export TASK_DEFINITION=$(cat deployment-config/ecs-task-definition.json)
export UPDATED_TASK_DEFINITION=$(echo $TASK_DEFINITION | jq \
--arg IMAGE "${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ env.AWS_REGION }}.amazonaws.com/${{ env.APPLICATION_NAME }}:$SHA"
--arg IMAGE "${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ env.AWS_REGION }}.amazonaws.com/${{ env.APPLICATION_NAME }}:$SHA" \
'.containerDefinitions[0].image = $IMAGE')
echo $UPDATED_TASK_DEFINITION > new-task-def.json
aws ecs register-task-definition --cli-input-json file://new-task-def.json

Expand Down
12 changes: 6 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
# Base image
FROM node:20-alpine as builder
FROM node:20-alpine AS builder

# Set the working directory
WORKDIR /app

# Copy the package.json and package-lock.json files
COPY package*.json .

# Install the dependencies
RUN npm install

# Copy the app files
COPY . .

# Install the dependencies
RUN npm install

# Build the app
RUN npm run build

# Build base image on nginx
FROM nginx:1.19.0
WORKDIR /usr/share/nginx/html
RUN rm -rf ./*
COPY --from=builder /app/build .
ENTRYPOINT ["nginx", "-g", "daemon off;"]
COPY --from=builder /app/dist .
ENTRYPOINT ["nginx", "-g", "daemon off;"]
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,10 @@ To run the application locally, follow these steps:


By default, the application will run on [http://localhost:3000](http://localhost:3000).

### CICD
Merge to master will trigger CICD pipeline that has following stages:
- Build App and the Docker image
- Push Docker image to the registry
- Update deployment configuration file to contain newly built image tag
- Deploy new deployment configuration
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"taskDefinitionArn": "arn:aws:ecs:eu-west-1:654654270781:task-definition/rbc-library-fe:1",
"family": "rbc-library-fe",
"containerDefinitions": [
{
"name": "rbc-lib-fe",
Expand All @@ -9,8 +9,8 @@
"portMappings": [
{
"name": "rbc-lib-fe",
"containerPort": 81,
"hostPort": 81,
"containerPort": 80,
"hostPort": 80,
"protocol": "tcp"
}
],
Expand Down Expand Up @@ -39,65 +39,30 @@
"systemControls": []
}
],
"family": "rbc-library-fe",
"taskRoleArn": "arn:aws:iam::654654270781:role/rbc-library-fe-20241016144507599100000001",
"executionRoleArn": "arn:aws:iam::654654270781:role/rbc-library-fe-20241016144507640300000004",
"networkMode": "awsvpc",
"revision": 1,
"volumes": [],
"status": "ACTIVE",
"requiresAttributes": [
{
"name": "com.amazonaws.ecs.capability.logging-driver.awslogs"
},
{
"name": "ecs.capability.execution-role-awslogs"
},
{
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.19"
},
{
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.17"
},
{
"name": "com.amazonaws.ecs.capability.task-iam-role"
},
"tags": [
{
"name": "ecs.capability.container-ordering"
"key": "Owner",
"value": "rbc"
},
{
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.18"
"key": "GithubRepo",
"value": "rbc3-infra-aws"
},
{
"name": "ecs.capability.task-eni"
"key": "GithubOrg",
"value": "ProductDock"
}
],
"taskRoleArn": "arn:aws:iam::654654270781:role/rbc-library-fe-20241016144507599100000001",
"executionRoleArn": "arn:aws:iam::654654270781:role/rbc-library-fe-20241016144507640300000004",
"networkMode": "awsvpc",
"volumes": [],
"placementConstraints": [],
"compatibilities": [
"EC2",
"FARGATE"
],
"requiresCompatibilities": [
"EC2"
],
"runtimePlatform": {
"cpuArchitecture": "X86_64",
"operatingSystemFamily": "LINUX"
},
"registeredAt": "2024-10-16T14:45:09.292Z",
"registeredBy": "arn:aws:sts::654654270781:assumed-role/terraform/GitHubActions",
"tags": [
{
"key": "Owner",
"value": "rbc"
},
{
"key": "GithubRepo",
"value": "rbc3-infra-aws"
},
{
"key": "GithubOrg",
"value": "ProductDock"
}
]
}
}