Skip to content

Commit 304e454

Browse files
committed
Used Code-Deploy manual
1 parent b1ed0e1 commit 304e454

File tree

4 files changed

+64
-1
lines changed

4 files changed

+64
-1
lines changed

appspec.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
version: 0.0
2+
os: linux
3+
files:
4+
- source: /
5+
destination: /home/ubuntu/app
6+
hooks:
7+
BeforeInstall:
8+
- location: deploy/scripts/install_dependencies.sh
9+
timeout: 300
10+
runas: ubuntu
11+
ApplicationStart:
12+
- location: deploy/scripts/start_docker.sh
13+
timeout: 300
14+
runas: ubuntu
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/bash
2+
3+
# Ensure that the script runs in non-interactive mode
4+
export DEBIAN_FRONTEND=noninteractive
5+
6+
# Update the package lists
7+
sudo apt-get update -y
8+
9+
# Install Docker
10+
sudo apt-get install -y docker.io
11+
12+
# Start and enable Docker service
13+
sudo systemctl start docker
14+
sudo systemctl enable docker
15+
16+
# Install necessary utilities
17+
sudo apt-get install -y unzip curl
18+
19+
# Download and install AWS CLI
20+
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "/home/ubuntu/awscliv2.zip"
21+
unzip -o /home/ubuntu/awscliv2.zip -d /home/ubuntu/
22+
sudo /home/ubuntu/aws/install
23+
24+
# Add 'ubuntu' user to the 'docker' group to run Docker commands without 'sudo'
25+
sudo usermod -aG docker ubuntu
26+
27+
# Clean up the AWS CLI installation files
28+
rm -rf /home/ubuntu/awscliv2.zip /home/ubuntu/aws

deploy/scripts/start_docker.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
# Login to AWS ECR
3+
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
4+
5+
# Pull the latest image
6+
docker pull 843369994444.dkr.ecr.eu-north-1.amazonaws.com/text-classification:v3
7+
8+
# Check if the container 'campusx-app' is running
9+
if [ "$(docker ps -q -f name=text-classification)" ]; then
10+
# Stop the running container
11+
docker stop text-classification
12+
fi
13+
14+
# Check if the container 'campusx-app' exists (stopped or running)
15+
if [ "$(docker ps -aq -f name=text-classification)" ]; then
16+
# Remove the container if it exists
17+
docker rm text-classification
18+
fi
19+
20+
# Run a new container
21+
docker run -d -p 80:5000 -e DAGSHUB_PAT=319a47e590ec9cc01014f4b6e8805468766d0757 --name text-classification 843369994444.dkr.ecr.eu-north-1.amazonaws.com/text-classification:v3

flask_app/templates/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<head>
33
<title>Sentiment Analysis</title>
44
</head>
5-
<body>
5+
<body style="background-color: aqua;">
66
<h1>Sentiment Analysis</h1>
77
<form action="/predict" method="POST">
88
<label for="">Write text:</label><br>

0 commit comments

Comments
 (0)