adding scripts + appspec.yml file for codedeploy

This commit is contained in:
Piasecki-grid 2025-01-31 12:15:48 +01:00
parent 1d1d1d771b
commit 182576ff00
3 changed files with 45 additions and 0 deletions

24
appspec.yml Normal file
View file

@ -0,0 +1,24 @@
version: 0.0
os: linux
files:
- source: /target/*.jar
destination: /home/ec2-user/spring-petclinic
permissions:
- object: /home/ec2-user/spring-petclinic
owner: ec2-user
group: ec2-user
mode: 755
hooks:
BeforeInstall:
- location: scripts/before_install.sh
timeout: 300
runas: ec2-user
ApplicationStart:
- location: scripts/start_application.sh
timeout: 300
runas: ec2-user

10
scripts/before_install.sh Normal file
View file

@ -0,0 +1,10 @@
#!/bin/bash
echo "Updating package list..."
sudo yum update -y
sudo yum install -y openjdk-21-jdk
echo "Installing Maven..."
sudo yum install -y maven

View file

@ -0,0 +1,11 @@
#!/bin/bash
echo "Navigating to the application directory..."
cd /home/ec2-user/spring-petclinic
echo "Building the application using Maven..."
mvn clean package -DskipTests
echo "Starting the Spring Boot application..."
java -jar target/spring-petclinic-*.jar > app.log 2>&1 &
echo "Application started successfully!"