diff --git a/Dockerfile.build b/Dockerfile.build index aec80618c..ea28c089b 100644 --- a/Dockerfile.build +++ b/Dockerfile.build @@ -1,5 +1,3 @@ FROM openjdk:8-jdk-alpine WORKDIR /build -COPY . . -RUN ./mvnw -B -e dependency:go-offline -RUN ./mvnw package +CMD [ "./build.sh" ] diff --git a/Dockerfile.run b/Dockerfile.run index bebeb0f05..c7765ed77 100644 --- a/Dockerfile.run +++ b/Dockerfile.run @@ -1,5 +1,5 @@ FROM openjdk:8-jre-alpine -WORKDIR /app/target -COPY app.jar . +WORKDIR /app EXPOSE 8080 CMD [ "java", "-jar", "-Dspring.profiles.active=mysql" ,"app.jar" ] +COPY /target/app.jar . diff --git a/Jenkinsfile b/Jenkinsfile index 3dfd726e7..c55a234b8 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -9,11 +9,11 @@ pipeline { dockerfile { filename 'Dockerfile.build' dir '.' - args '-v $HOME/.m2:/root/.m2 --name petclinic_build' + args '-v $HOME/.m2:/root/.m2' } } steps { - sh 'docker cp petclinic_build:/build/target/app.jar .' + echo 'Build done' } } diff --git a/build.sh b/build.sh new file mode 100755 index 000000000..4c415af54 --- /dev/null +++ b/build.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +if [[ -f spring-petclinic ]]; then + cd spring-petclinic + git chekcout jenkins + git pull jenkins +else + git clone https://github.com/hllvc/spring-petclinic.git + cd spring-petclinic + git checkout jenkins +fi + +./mvnw package