Skip to content

Commit cffe6de

Browse files
authored
Merge pull request #1 from HimanM/test
Test
2 parents 7e1557d + d2c0c5c commit cffe6de

26 files changed

+992
-454
lines changed

.github/workflows/check-deploy.yml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: Check Deploy Strategy
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
check-and-deploy:
10+
name: Check Deploy Strategy
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v4
16+
17+
- name: Check DEPLOY_AWS secret
18+
id: check-deploy
19+
run: |
20+
if [ "${{ secrets.DEPLOY_AWS }}" == "true" ]; then
21+
echo "deploy_to_aws=true" >> $GITHUB_OUTPUT
22+
echo "Deploy to AWS ECS"
23+
else
24+
echo "deploy_to_aws=false" >> $GITHUB_OUTPUT
25+
echo "Deploy to GitHub Pages"
26+
fi
27+
28+
- name: Trigger AWS Deployment
29+
if: steps.check-deploy.outputs.deploy_to_aws == 'true'
30+
uses: actions/github-script@v7
31+
with:
32+
github-token: ${{ secrets.GITHUB_TOKEN }}
33+
script: |
34+
await github.rest.actions.createWorkflowDispatch({
35+
owner: context.repo.owner,
36+
repo: context.repo.repo,
37+
workflow_id: 'deploy.yml',
38+
ref: context.ref
39+
});
40+
41+
- name: Setup Node.js
42+
if: steps.check-deploy.outputs.deploy_to_aws == 'false'
43+
uses: actions/setup-node@v4
44+
with:
45+
node-version: '20'
46+
cache: 'npm'
47+
cache-dependency-path: './aws-deploy-guide/package-lock.json'
48+
49+
- name: Install dependencies
50+
if: steps.check-deploy.outputs.deploy_to_aws == 'false'
51+
working-directory: ./aws-deploy-guide
52+
run: npm ci
53+
54+
- name: Build for GitHub Pages
55+
if: steps.check-deploy.outputs.deploy_to_aws == 'false'
56+
working-directory: ./aws-deploy-guide
57+
run: npm run build
58+
env:
59+
NEXT_PUBLIC_BASE_PATH: ''
60+
61+
- name: Add .nojekyll file
62+
if: steps.check-deploy.outputs.deploy_to_aws == 'false'
63+
working-directory: ./aws-deploy-guide
64+
run: touch out/.nojekyll
65+
66+
- name: Add CNAME file
67+
if: steps.check-deploy.outputs.deploy_to_aws == 'false'
68+
working-directory: ./aws-deploy-guide
69+
run: echo "devops4.himanmanduja.fun" > out/CNAME
70+
71+
- name: Deploy to GitHub Pages
72+
if: steps.check-deploy.outputs.deploy_to_aws == 'false'
73+
uses: peaceiris/actions-gh-pages@v3
74+
with:
75+
github_token: ${{ secrets.GITHUB_TOKEN }}
76+
publish_dir: ./aws-deploy-guide/out
77+
cname: devops4.himanmanduja.fun

.github/workflows/deploy.yml

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
name: Deploy to Amazon ECS
22

33
on:
4-
push:
5-
branches:
6-
- main
4+
workflow_dispatch:
75

86
env:
97
AWS_REGION: ${{ secrets.AWS_REGION }} # set this to your preferred AWS region, e.g. us-west-1
@@ -27,15 +25,15 @@ jobs:
2725
uses: actions/checkout@v4
2826

2927
- name: Configure AWS credentials
30-
uses: aws-actions/configure-aws-credentials@v1
28+
uses: aws-actions/configure-aws-credentials@v4
3129
with:
3230
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
3331
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
3432
aws-region: ${{ env.AWS_REGION }}
3533

3634
- name: Login to Amazon ECR
3735
id: login-ecr
38-
uses: aws-actions/amazon-ecr-login@v1
36+
uses: aws-actions/amazon-ecr-login@v2
3937

4038
- name: Build, tag, and push image to Amazon ECR
4139
id: build-image
@@ -58,15 +56,15 @@ jobs:
5856

5957
steps:
6058
- name: Configure AWS credentials
61-
uses: aws-actions/configure-aws-credentials@v1
59+
uses: aws-actions/configure-aws-credentials@v4
6260
with:
6361
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
6462
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
6563
aws-region: ${{ env.AWS_REGION }}
6664

6765
- name: Login to Amazon ECR
6866
id: login-ecr
69-
uses: aws-actions/amazon-ecr-login@v1
67+
uses: aws-actions/amazon-ecr-login@v2
7068

7169
- name: Download Task Definition
7270
run: |
@@ -82,7 +80,7 @@ jobs:
8280
image: ${{ steps.login-ecr.outputs.registry }}/${{ env.ECR_REPOSITORY }}:${{ github.sha }}
8381

8482
- name: Deploy Amazon ECS task definition
85-
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
83+
uses: aws-actions/amazon-ecs-deploy-task-definition@v2
8684
with:
8785
task-definition: ${{ steps.task-def.outputs.task-definition }}
8886
service: ${{ env.ECS_SERVICE }}

README.md

Lines changed: 134 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,156 @@
1-
# Guide to Deploy a Container in AWS
1+
# AWS Deployment Guide and DevOps Project Hub
22

3-
This is a Next.js application that serves as a comprehensive guide for deploying containerized applications on AWS ECS Fargate. It includes a step-by-step workflow, prerequisites, and links to other DevOps projects.
3+
![Project Home](docs/guide_home.png)
44

5-
## Features
5+
This repository contains a Next.js application designed to serve as a comprehensive, interactive guide for deploying containerized applications to AWS ECS Fargate. It documents the entire DevOps lifecycle, from configuring AWS credentials to setting up a CI/CD pipeline with GitHub Actions.
66

7-
- **Interactive Guide**: Step-by-step instructions for AWS deployment.
8-
- **Modern UI**: Built with shadcn/ui and Tailwind CSS in a dark theme.
9-
- **Animations**: Smooth workflow animations using Framer Motion.
10-
- **Project Hub**: Links to other DevOps projects.
7+
The application itself is a hands-on learning tool, featuring a step-by-step workflow visualization, detailed command explanations, and a centralized dashboard for other DevOps projects.
118

12-
## Getting Started
9+
## Project Overview
1310

14-
First, run the development server:
11+
The primary goal of this project is to demystify the process of deploying a Dockerized application to the cloud. It breaks down complex AWS tasks into manageable steps, providing visual aids and direct links to necessary resources.
1512

16-
```bash
17-
npm run dev
18-
```
13+
### Key Features
1914

20-
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
15+
* **Interactive Deployment Workflow**: A guided experience through the AWS deployment process.
16+
* **Mobile-Optimized Design**: A responsive interface that works seamlessly on desktop and mobile devices.
17+
* **Automated CI/CD**: A fully functional GitHub Actions pipeline for continuous deployment.
18+
* **DevOps Dashboard**: A collection of links to related DevOps initiatives.
2119

22-
## CI/CD Pipeline (GitHub Actions)
20+
## Technical Architecture
2321

24-
This project includes a GitHub Actions workflow (`.github/workflows/deploy.yml`) that automatically builds and deploys the application to AWS ECS whenever changes are pushed to the `main` branch.
22+
* **Frontend Framework**: Next.js 14 (React)
23+
* **Styling**: Tailwind CSS
24+
* **UI Components**: Shadcn/UI, Lucide Icons
25+
* **Infrastructure**: AWS ECS (Fargate), AWS ECR, AWS IAM
26+
* **Containerization**: Docker
27+
* **CI/CD**: GitHub Actions
2528

26-
### Prerequisites for CI/CD
27-
You must configure the following **Secrets** in your GitHub Repository (Settings > Secrets and variables > Actions):
29+
## Deployment Walkthrough
2830

29-
| Secret Name | Description | Example Value |
30-
| :--- | :--- | :--- |
31-
| `AWS_ACCESS_KEY_ID` | Your AWS Access Key ID | `AKIA...` |
32-
| `AWS_SECRET_ACCESS_KEY` | Your AWS Secret Access Key | `wJalr...` |
33-
| `AWS_REGION` | AWS Region | `us-west-2` |
34-
| `ECR_REPOSITORY` | Name of your ECR Repository | `aws-deploy-guide` |
35-
| `ECS_CLUSTER` | Name of your ECS Cluster | `aws-deploy-guide-cluster` |
36-
| `ECS_SERVICE` | Name of your ECS Service | `aws-deploy-guide-task-service` |
37-
| `ECS_TASK_DEFINITION` | Name of your Task Definition Family | `aws-deploy-guide-task` |
38-
| `CONTAINER_NAME` | Name of the container in Task Def | `aws-deploy-guide-container` |
31+
This section documents every step required to deploy the application, corresponding to the interactive guide within the app.
3932

40-
### Workflow Stages
41-
1. **Build and Push:** Builds the Docker image and pushes it to Amazon ECR.
42-
2. **Deploy to ECS:** Updates the ECS Task Definition with the new image and deploys it to the ECS Service.
33+
### 1. AWS Configuration
4334

44-
## Docker Deployment
35+
The first step involves setting up the necessary permissions and tools to interact with AWS.
4536

46-
This project includes a `Dockerfile` to containerize the application.
37+
**Create Access Keys**
38+
Generate programmatic access keys in the AWS IAM Console to allow the AWS CLI to authenticate.
39+
![AWS Access Keys](docs/access_keys_created.png)
4740

48-
### Build the Docker Image
41+
### 2. Container Registry (ECR)
4942

50-
```bash
51-
docker build -t aws-deploy-guide .
52-
```
43+
Amazon Elastic Container Registry (ECR) is used to store the Docker images.
5344

54-
### Run the Container Locally
45+
**Create Repository**
46+
A new repository is created to host the application image.
47+
![ECR Repository List](docs/repo_list.png)
5548

56-
```bash
57-
docker run -p 3000:3000 aws-deploy-guide
58-
```
49+
**Push Commands**
50+
The AWS CLI provides specific commands to authenticate Docker and push the image.
51+
![Push Commands](docs/push_commands.png)
5952

60-
Access the application at `http://localhost:3000`.
53+
**Successful Push**
54+
Verifying that the image has been successfully uploaded to ECR.
55+
![CLI Push Success](docs/cli_push_success.png)
6156

62-
## AWS Deployment Steps (Summary)
57+
**Repository Content**
58+
The ECR repository now contains the tagged Docker image.
59+
![ECR Repo with Image](docs/ecr_repo_with_image.png)
6360

64-
1. **Login to AWS**: Configure CLI and login to ECR.
65-
2. **Push Image**: Tag and push your Docker image to ECR.
66-
3. **Create Cluster**: Set up an ECS Fargate cluster.
67-
4. **Deploy Service**: Create a task definition and service to run your container.
68-
5. **Access**: Use the public IP assigned to your task.
61+
### 3. ECS Cluster Setup
6962

70-
For detailed steps, run the application and follow the interactive guide.
63+
Amazon Elastic Container Service (ECS) is the orchestration service used to run the containers.
64+
65+
**Cluster Creation Form**
66+
Configuring a new Fargate cluster in the AWS Console.
67+
![ECS Cluster Creation Form](docs/ecs_cluster_creation_form.png)
68+
69+
**Cluster Created**
70+
The ECS Cluster is successfully provisioned and ready to host services.
71+
![ECS Cluster Created](docs/ecs_cluster_created.png)
72+
73+
### 4. Task Definition
74+
75+
The Task Definition serves as a blueprint for the application, specifying the container image, CPU, and memory requirements.
76+
77+
**Configure Task Definition (Step 1)**
78+
Setting the task family name and infrastructure requirements.
79+
![New Task Definition Form 1](docs/new_task_definition_form_1.png)
80+
81+
**Configure Container (Step 2)**
82+
Specifying the container details and port mappings.
83+
![New Task Definition Form 2](docs/new_task_definition_form_2.png)
84+
85+
**Select Image URI**
86+
Using the URI of the image pushed to ECR earlier.
87+
![ECR Image Selection](docs/ecr_image_selection_on_new_task_def.png)
88+
89+
**Task Definition Created**
90+
The task definition is successfully registered.
91+
![Task Definition Success](docs/task_definition_creation_success.png)
92+
93+
### 5. Service Deployment
94+
95+
The ECS Service maintains the desired number of tasks and handles networking.
96+
97+
**Create Service (Step 1)**
98+
Defining the service name and desired task count.
99+
![Create Service Form 1](docs/create_service_form_1.png)
100+
101+
**Environment Configuration (Step 2)**
102+
Setting up the deployment type and platform version.
103+
![Create Service Form 2](docs/create_service_form_2_env.png)
104+
105+
**Deployment Settings (Step 3)**
106+
Configuring deployment strategies (e.g., rolling updates).
107+
![Create Service Form 3](docs/create_service_form_3_deployment.png)
108+
109+
**Networking (Step 4)**
110+
Defining the VPC, subnets, and security groups for the service.
111+
![Create Service Form 4](docs/create_service_form_4_networking.png)
112+
113+
**Service Created**
114+
The service is successfully created and begins provisioning tasks.
115+
![Service Creation Success](docs/service_creation_success.png)
116+
117+
### 6. Verification
118+
119+
Once the service is stable, the application is accessible via the public IP of the Fargate task.
120+
121+
**Access Application**
122+
The application is live and accessible in the browser.
123+
![Access Application](docs/access_application.png)
124+
125+
**Deployed Dashboard**
126+
The live dashboard showing the successful deployment.
127+
![Deployed Application](docs/deployed_application.png)
128+
129+
## CI/CD Pipeline
130+
131+
The project includes a GitHub Actions workflow to automate the build and deploy process.
132+
133+
**GitHub Secrets**
134+
Securely storing AWS credentials and configuration variables in GitHub.
135+
![GitHub Secrets](docs/github_secrets.png)
136+
137+
**Workflow Visualization**
138+
The GitHub Actions interface showing the progress of the build and deploy jobs.
139+
![GitHub Workflow](docs/github_workflow.png)
140+
141+
### Required Secrets
142+
143+
To enable the CI/CD pipeline, the following secrets must be configured in the GitHub Repository:
144+
145+
* AWS_ACCESS_KEY_ID
146+
* AWS_SECRET_ACCESS_KEY
147+
* AWS_REGION
148+
* ECR_REPOSITORY
149+
* ECS_CLUSTER
150+
* ECS_SERVICE
151+
* ECS_TASK_DEFINITION
152+
* CONTAINER_NAME
153+
154+
## Educational Project Disclaimer
155+
156+
This is an educational project designed to demonstrate DevOps best practices and modern web development techniques. Anyone is free to fork this repository and modify anything to suit their own learning needs or project requirements.

aws-deploy-guide/next.config.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ import type { NextConfig } from "next";
33
const nextConfig: NextConfig = {
44
/* config options here */
55
reactCompiler: true,
6+
output: 'export',
7+
images: {
8+
unoptimized: true,
9+
},
610
};
711

812
export default nextConfig;

aws-deploy-guide/package-lock.json

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

aws-deploy-guide/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"next": "16.0.5",
2424
"react": "19.2.0",
2525
"react-dom": "19.2.0",
26+
"react-icons": "^5.5.0",
2627
"tailwind-merge": "^3.4.0"
2728
},
2829
"devDependencies": {
@@ -31,6 +32,7 @@
3132
"@types/react": "^19",
3233
"@types/react-dom": "^19",
3334
"babel-plugin-react-compiler": "1.0.0",
35+
"baseline-browser-mapping": "^2.8.32",
3436
"eslint": "^9",
3537
"eslint-config-next": "16.0.5",
3638
"tailwindcss": "^4",
13.3 KB
Loading
140 KB
Loading
73.3 KB
Loading
42.9 KB
Loading

0 commit comments

Comments
 (0)