Skip to content

Commit 775371c

Browse files
committed
DevOps: Push DevOps-Project-23
* DevSecOps: Blue-Green Deployment of Swiggy-Clone on AWS ECS with AWS Code Pipeline Signed-off-by: NotHarshhaa <reddyharshhaa12@gmail.com>
1 parent 6f6aded commit 775371c

30 files changed

+19553
-0
lines changed

DevOps-Project-23/README.md

Lines changed: 550 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Use Node.js 16 slim as the base image
2+
FROM node:16
3+
4+
# Set the working directory
5+
WORKDIR /app
6+
7+
# Copy package.json and package-lock.json to the working directory
8+
COPY package*.json ./
9+
10+
# Install dependencies
11+
RUN npm install
12+
13+
# Copy the rest of the application code
14+
COPY . .
15+
16+
# Build the React app
17+
RUN npm run build
18+
19+
# Expose port 3000 (or the port your app is configured to listen on)
20+
EXPOSE 3000
21+
22+
# Start your Node.js server (assuming it serves the React app)
23+
CMD ["npm", "start"]
Loading
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
version: 0.0
2+
Resources:
3+
- TargetService:
4+
Type: AWS::ECS::Service
5+
Properties:
6+
TaskDefinition: "arn:aws:ecs:ap-south-1:590184124026:task-definition/swiggy:1"
7+
LoadBalancerInfo:
8+
ContainerName: "swiggy"
9+
ContainerPort: 3000
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
version: 0.2
2+
3+
env:
4+
parameter-store:
5+
DOCKER_REGISTRY_USERNAME: /cicd/docker-credentials/username
6+
DOCKER_REGISTRY_PASSWORD: /cicd/docker-credentials/password
7+
DOCKER_REGISTRY_URL: /cicd/docker-registry/url
8+
SONAR_TOKEN: /cicd/sonar/sonar-token
9+
phases:
10+
install:
11+
runtime-versions:
12+
python: 3.11
13+
java: corretto17
14+
pre_build:
15+
commands:
16+
- echo "Installing dependencies..."
17+
- echo "Performing Trivy file scan before building the image..."
18+
# - wget https://github.com/aquasecurity/trivy/releases/download/v0.19.2/trivy_0.19.2_Linux-64bit.tar.gz
19+
# - tar zxvf trivy_0.19.2_Linux-64bit.tar.gz
20+
# - export PATH=$PATH:$PWD
21+
# - trivy filesystem --exit-code 0 --no-progress . >> trivyfilescan.txt
22+
# - echo "Downloading and installing OWASP Dependency-Check..."
23+
# - wget https://github.com/jeremylong/DependencyCheck/releases/download/v7.0.2/dependency-check-7.0.2-release.zip
24+
# - unzip dependency-check-7.0.2-release.zip
25+
# - export SONAR_SCANNER_VERSION=4.7.0.2747
26+
# - export SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-linux
27+
# - curl --create-dirs -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SONAR_SCANNER_VERSION-linux.zip
28+
# - unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/
29+
# - export PATH=$SONAR_SCANNER_HOME/bin:$PATH
30+
# - export SONAR_SCANNER_OPTS="-server"
31+
32+
build:
33+
commands:
34+
- echo "Running tests..."
35+
- echo "Building Docker image..."
36+
# - echo "$DOCKER_REGISTRY_PASSWORD" | docker login -u "$DOCKER_REGISTRY_USERNAME" --password-stdin "$DOCKER_REGISTRY_URL"
37+
# - docker build -t "$DOCKER_REGISTRY_URL/$DOCKER_REGISTRY_USERNAME/swiggy:latest" .
38+
# - docker push "$DOCKER_REGISTRY_URL/$DOCKER_REGISTRY_USERNAME/swiggy:latest"
39+
# post_build:
40+
# commands:
41+
# - echo "Performing Trivy image scan after building the image..."
42+
# - aws ses send-email --from "madithati123@gmail.com" --to "madithatisreedhar123@gmail.com" --subject "CodeBuild Status: $CODEBUILD_BUILD_ID" --text "Build status: $CODEBUILD_BUILD_STATUS" --region "ap-south-1"
43+
44+
# # - trivy image "$DOCKER_REGISTRY_USERNAME/swiggy:latest" >> trivyimage.txt
45+
# # - echo "Running OWASP Dependency-Check scan..."
46+
# # - cd dependency-check/bin
47+
# # - ./dependency-check.sh --scan . --format ALL
48+
# # - echo "Build completed successfully!"
49+
# # - echo "Running SonarQube analysis result"
50+
# # - sonar-scanner -Dsonar.projectKey=swiggy -Dsonar.sources=. -Dsonar.host.url=http://65.1.1.149:9000/
51+
# #- aws ses send-email --from "madithati123@gmail.com" --to "madithatisreedhar123@gmail.com" --subject "CodeBuild Status: $CODEBUILD_BUILD_ID" --text "Build status: $CODEBUILD_BUILD_STATUS" --region "ap-south-1"
52+
# # Update with your preferred AWS region
53+
54+
post_build:
55+
commands:
56+
- aws ses send-email \
57+
--from "madithati123@gmail.com" \
58+
--to "madithati123@gmail.com" \
59+
--subject "CodeBuild Status: $CODEBUILD_BUILD_ID" \
60+
--text "Build status: $CODEBUILD_BUILD_STATUS" \
61+
--region "us-east-1" # Update with your preferred AWS region
62+
63+
64+
artifacts:
65+
files:
66+
- appspec.yaml

0 commit comments

Comments
 (0)