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
environment {
BUILD_CONTAINER_ID = ''
}
stages {
stage('Build') {
agent {
dockerfile {
filename 'Dockerfile.build'
dir '.'
additionalBuildArgs '-t petclinic-build'
args '-v $HOME/.m2:/root/.m2'
}
args '$HOME/.m2:/root/.m2'
}
steps {
script {
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 .'
BUILD_CONTAINER_ID = "sh 'docker run -v $HOME/.m2:/root/.m2 -d petclinic-build'"
}
}
stage('Run') {
agent {
dockerfile {
filename 'Dockerfile.run'
dir '.'
}
additionalBuildArgs '-t petclinic-run'
}
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:
app:
image: hllvc/spring-petclinic:latest
image: petclinic-run
links:
- mysql:mysql
ports: