From 3ac5836e8c29b2a81c0bb80212004e28b84f8b82 Mon Sep 17 00:00:00 2001 From: Macclare Date: Mon, 12 May 2025 20:16:13 +0100 Subject: [PATCH 1/3] updated with jenkinsfile and dockerfile --- Dockerfile | 11 +++++++++ Jenkinsfile | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+) create mode 100644 Dockerfile create mode 100644 Jenkinsfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..4035095 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,11 @@ +# Use an official Tomcat image as a base image +FROM tomcat:9-jdk11-openjdk + +# Copy the WAR file into Tomcat's webapps directory (relative path from Docker build context) +COPY target/WebAppCal-0.0.6.war /usr/local/tomcat/webapps/WebAppCal-0.0.6.war + +# Expose the default Tomcat port +EXPOSE 8080 + +# Start Tomcat when the container starts +CMD ["catalina.sh", "run"] diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..03076c0 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,66 @@ +pipeline { + agent any + + environment { + DOCKER_IMAGE = "macclare/my-webapp" + WAR_FILE = "target/WebAppCal-0.0.6.war" + DOCKER_REGISTRY = "docker.io" + } + + stages { + stage('Checkout') { + steps { + + checkout scm + } + } + + stage('Build') { + steps { + script { + // Run Maven to build the WAR file + sh 'mvn clean install' + } + } + } + + stage('Build Docker Image') { + steps { + script { + // Build Docker image + sh """ + docker build -t ${DOCKER_IMAGE} . + """ + } + } + } + + stage('Run Docker Container') { + steps { + script { + // Run the Docker container with Tomcat + sh """ + docker run -d -p 8080:8080 ${DOCKER_IMAGE} + """ + } + } + } + + stage('Deploy') { + steps { + // Deploy the WAR file to the running Tomcat server, you may want to SSH into the server + echo 'Deploying the application...' + } + } + } + + post { + success { + echo 'Deployment was successful!' + } + + failure { + echo 'There was an issue with the build/deployment.' + } + } +} From 2d01ff34f9f180958c27b5c22e9108b9d201b961 Mon Sep 17 00:00:00 2001 From: Macclare Date: Mon, 12 May 2025 20:33:50 +0100 Subject: [PATCH 2/3] updated pom.xml file --- pom.xml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/pom.xml b/pom.xml index 9e1759e..c86c639 100644 --- a/pom.xml +++ b/pom.xml @@ -27,4 +27,17 @@ http://52.204.135.48:8081/nexus/content/repositories/releases + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 + + 1.8 + 1.8 + + + + From 8daab874edb307c96ba1d1310132a68753faa956 Mon Sep 17 00:00:00 2001 From: Macclare Date: Mon, 12 May 2025 20:42:42 +0100 Subject: [PATCH 3/3] updated war plugin --- pom.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pom.xml b/pom.xml index c86c639..2c26a0d 100644 --- a/pom.xml +++ b/pom.xml @@ -38,6 +38,11 @@ 1.8 + + org.apache.maven.plugins + maven-war-plugin + 3.3.2 +