Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
DharshiBalasubramaniyam committed Jul 3, 2024
2 parents 6fa837d + fbf51f1 commit 083d129
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 16 deletions.
24 changes: 14 additions & 10 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# This workflow will build docker image and push it to DockerHub,
# After that, This wrkflow build and push a new container image to Amazon ECR,
# and then will deploy a new task definition to Amazon ECS, when there is a push to the "main" branch.

name: CI/CD Pipeline # Name of the CI/CD Pipeline

on:
Expand All @@ -24,14 +28,14 @@ jobs:
- name: Build with Maven # Step to build the project with Maven
run: mvn clean install

# - name: Login to DockerHub # Step to login to DockerHub
# run: docker login -u ${{secrets.DOCKER_USERNAME}} -p ${{secrets.DOCKER_PASSWORD}}

# - name: Build Docker image # Step to build the Docker image
# run: docker build -t dharshib/springboot-ci-cd .

# - name: Push the image to DockerHub # Step to push the Docker image to DockerHub
# run: docker push dharshib/springboot-ci-cd:latest
- name: build and push the docker image to dockerhub
run: |
# 1. Login to DockerHub
# 2. Build the Docker image
# 3. Push the Docker image to DockerHub
docker login -u ${{secrets.DOCKER_USERNAME}} -p ${{secrets.DOCKER_PASSWORD}}
docker build -t dharshib/springboot-ci-cd .
docker push dharshib/springboot-ci-cd:latest
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
Expand Down Expand Up @@ -60,15 +64,15 @@ jobs:
# Updating our ECS task definition file with the newly built Docker image ID
# after successfully building and pushing the Docker image to Amazon ECR.
- name: Fill in the new image ID in the Amazon ECS task definition
- name: Update ECS task definition with new image
id: task-def
uses: aws-actions/amazon-ecs-render-task-definition@v1
with:
task-definition: ${{ secrets.ECS_TASK_DEFINITION }}
container-name: ${{ secrets.CONTAINER_NAME }}
image: ${{ steps.build-image.outputs.image }}

- name: Deploy Amazon ECS task definition
- name: Deploy the updated ECS task definition
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
with:
task-definition: ${{ steps.task-def.outputs.task-definition }}
Expand Down
15 changes: 9 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
<img alt="Static Badge" src="https://img.shields.io/badge/Spring%20Boot-green?style=for-the-badge">
<img alt="Static Badge" src="https://img.shields.io/badge/GitHub%20Actions-purple?style=for-the-badge">
<img alt="Static Badge" src="https://img.shields.io/badge/Docker-blue?style=for-the-badge">
<img alt="Static Badge" src="https://img.shields.io/badge/AWS-red?style=for-the-badge">
<img alt="Static Badge" src="https://img.shields.io/badge/amazon%20ecs-red?style=for-the-badge">
<img alt="Static Badge" src="https://img.shields.io/badge/amazon%20ecr-red?style=for-the-badge">
<img alt="Static Badge" src="https://img.shields.io/badge/aws%20fargate-red?style=for-the-badge">
<img alt="Static Badge" src="https://img.shields.io/badge/amazon%20elb-red?style=for-the-badge">
</p>

## 🌟 Description
Expand Down Expand Up @@ -182,11 +185,11 @@ For example, we might have a web server container and a database container defin
## ECS workflow
1. Create a cluster.
2. Create a service within the cluster.
3. Define Task definition.
4. Setup EC2 instances (Opt for the EC2 launch type).
5. Set Up Load Balancing (Optional).
1. Create an ECR repository to store your images.
2. Create an ECS task definition, an ECS cluster, and an ECS service.
3. Setup EC2 instances (Opt for the EC2 launch type).
4. Set Up Load Balancing (Optional).
5. Store your ECS task definition as a JSON file in your repository.
6. Create workflow file to automate CI/CD Integration with GitHubActions (check <a href="./.github/workflows/ci-cd.yml">ci-cd.yml</a> workflow file).
7. Access the endpoint of our deployed application in a browser. To access the endpoint of your deployed application in a browser.
- To access the endpoint of your deployed application, use the DNS name of your Elastic Load Balancer (ELB) by copying it and pasting it into your web browser's address bar.
Expand Down

0 comments on commit 083d129

Please sign in to comment.