From 182576ff00a5bb751589fd11b6f730e7778190cf Mon Sep 17 00:00:00 2001 From: Piasecki-grid Date: Fri, 31 Jan 2025 12:15:48 +0100 Subject: [PATCH] adding scripts + appspec.yml file for codedeploy --- appspec.yml | 24 ++++++++++++++++++++++++ scripts/before_install.sh | 10 ++++++++++ scripts/start_application.sh | 11 +++++++++++ 3 files changed, 45 insertions(+) create mode 100644 appspec.yml create mode 100644 scripts/before_install.sh create mode 100644 scripts/start_application.sh diff --git a/appspec.yml b/appspec.yml new file mode 100644 index 000000000..cc0ed17c4 --- /dev/null +++ b/appspec.yml @@ -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 + + diff --git a/scripts/before_install.sh b/scripts/before_install.sh new file mode 100644 index 000000000..66c8bc366 --- /dev/null +++ b/scripts/before_install.sh @@ -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 + + diff --git a/scripts/start_application.sh b/scripts/start_application.sh new file mode 100644 index 000000000..fb08fa699 --- /dev/null +++ b/scripts/start_application.sh @@ -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!" +