Skip to content

Commit

Permalink
Used Code-Deploy manual
Browse files Browse the repository at this point in the history
  • Loading branch information
2003HARSH committed Nov 19, 2024
1 parent b1ed0e1 commit 304e454
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 1 deletion.
14 changes: 14 additions & 0 deletions appspec.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: 0.0
os: linux
files:
- source: /
destination: /home/ubuntu/app
hooks:
BeforeInstall:
- location: deploy/scripts/install_dependencies.sh
timeout: 300
runas: ubuntu
ApplicationStart:
- location: deploy/scripts/start_docker.sh
timeout: 300
runas: ubuntu
28 changes: 28 additions & 0 deletions deploy/scripts/install_dependencies.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

# Ensure that the script runs in non-interactive mode
export DEBIAN_FRONTEND=noninteractive

# Update the package lists
sudo apt-get update -y

# Install Docker
sudo apt-get install -y docker.io

# Start and enable Docker service
sudo systemctl start docker
sudo systemctl enable docker

# Install necessary utilities
sudo apt-get install -y unzip curl

# Download and install AWS CLI
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "/home/ubuntu/awscliv2.zip"
unzip -o /home/ubuntu/awscliv2.zip -d /home/ubuntu/
sudo /home/ubuntu/aws/install

# Add 'ubuntu' user to the 'docker' group to run Docker commands without 'sudo'
sudo usermod -aG docker ubuntu

# Clean up the AWS CLI installation files
rm -rf /home/ubuntu/awscliv2.zip /home/ubuntu/aws
21 changes: 21 additions & 0 deletions deploy/scripts/start_docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash
# Login to AWS ECR
aws ecr get-login-password --region ap-southeast-2 | docker login --username AWS --password-stdin 843369994444.dkr.ecr.eu-north-1.amazonaws.com/text-classification:v3

# Pull the latest image
docker pull 843369994444.dkr.ecr.eu-north-1.amazonaws.com/text-classification:v3

# Check if the container 'campusx-app' is running
if [ "$(docker ps -q -f name=text-classification)" ]; then
# Stop the running container
docker stop text-classification
fi

# Check if the container 'campusx-app' exists (stopped or running)
if [ "$(docker ps -aq -f name=text-classification)" ]; then
# Remove the container if it exists
docker rm text-classification
fi

# Run a new container
docker run -d -p 80:5000 -e DAGSHUB_PAT=319a47e590ec9cc01014f4b6e8805468766d0757 --name text-classification 843369994444.dkr.ecr.eu-north-1.amazonaws.com/text-classification:v3
2 changes: 1 addition & 1 deletion flask_app/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<head>
<title>Sentiment Analysis</title>
</head>
<body>
<body style="background-color: aqua;">
<h1>Sentiment Analysis</h1>
<form action="/predict" method="POST">
<label for="">Write text:</label><br>
Expand Down

0 comments on commit 304e454

Please sign in to comment.