new aproach

This commit is contained in:
hllvc 2021-07-13 21:40:13 +02:00
parent d9beccecb0
commit 5c5ea6e1fa
2 changed files with 17 additions and 32 deletions

35
Jenkinsfile vendored
View file

@ -2,48 +2,33 @@ pipeline {
agent any agent any
environment {
BUILD_CONTAINER_ID = ''
}
stages { stages {
stage('Build') { stage('Build') {
agent {
dockerfile { dockerfile {
filename 'Dockerfile.build' filename 'Dockerfile.build'
dir '.' dir '.'
additionalBuildArgs '-t petclinic-build' additionalBuildArgs '-t petclinic-build'
args '-v $HOME/.m2:/root/.m2' args '$HOME/.m2:/root/.m2'
}
} }
steps { steps {
script { BUILD_CONTAINER_ID = "sh 'docker run -v $HOME/.m2:/root/.m2 -d petclinic-build'"
echo 'Done'
}
}
}
stage('Copy .jar file') {
agent {
docker {
image 'docker:dind'
args '-v /var/run/docker.sock:/var/run/docker.sock --user root'
}
}
steps {
sh """docker run -d \
-v /var/run/docker.sock:/var/run/docker.sock \
--name petclinic-build petclinic-build"""
sh 'docker cp petclinic-build:/build/target/app.jar .'
} }
} }
stage('Run') { stage('Run') {
agent {
dockerfile { dockerfile {
filename 'Dockerfile.run' filename 'Dockerfile.run'
dir '.' additionalBuildArgs '-t petclinic-run'
}
} }
steps { steps {
echo 'Done' sh 'docker cp ${BUILD_CONTAINER_ID}:/build/target/app.jar .'
sh 'docker-compose up'
/* sh 'docker run -it --rm -p 8080:8080 petclinic-run' */
} }
} }

View file

@ -1,6 +1,6 @@
services: services:
app: app:
image: hllvc/spring-petclinic:latest image: petclinic-run
links: links:
- mysql:mysql - mysql:mysql
ports: ports: