diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..08942b8 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,16 @@ +# Use an official Java runtime as a parent image +FROM tomcat:9-jdk11-openjdk-slim + +# Set the working directory +WORKDIR /usr/local/tomcat/webapps/ + +# Copy the WAR file into the container +COPY target/WebAppCal-0.0.6.war /usr/local/tomcat/webapps/ROOT.war + +# Expose the port +EXPOSE 8080 + +# Start Tomcat +CMD ["catalina.sh", "run"] + + diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..6997a08 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,42 @@ +pipeline { + agent any + + environment { + PATH = "/usr/bin:$PATH" + DOCKERHUB_CREDENTIALS = credentials('johnsonbv-creds-id') + } + + stages { + stage('Debug PATH') { + steps { + sh 'echo Current PATH: $PATH' + sh 'which docker' + sh 'docker --version || echo "Docker not found"' + } + } + + stage('Build') { + steps { + sh 'mvn clean package' + } + } + + stage('Build Docker Image') { + steps { + sh 'docker build -t johnsonbv/java-web-calculator .' + } + } + + stage('Push to Docker Hub') { + steps { + withCredentials([usernamePassword(credentialsId: 'johnsonbv-creds-id', passwordVariable: 'DOCKER_PASSWORD', usernameVariable: 'DOCKER_USERNAME')]) { + sh ''' + echo $DOCKER_PASSWORD | docker login -u $DOCKER_USERNAME --password-stdin + docker push johnsonbv/java-web-calculator + ''' + } + } + } + } +} + diff --git a/pom.xml b/pom.xml index 9e1759e..995c591 100644 --- a/pom.xml +++ b/pom.xml @@ -1,5 +1,7 @@ - + 4.0.0 com.web.cal WebAppCal @@ -14,17 +16,29 @@ 4.8.2 test - - - javax.servlet - servlet-api - 2.5 - - - - - releases - http://52.204.135.48:8081/nexus/content/repositories/releases - - + + javax.servlet + servlet-api + 2.5 + provided + + + + + + org.apache.maven.plugins + maven-war-plugin + 3.3.2 + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 + + 1.8 + 1.8 + + + +