diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 000000000..73ca4bfdf --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,52 @@ +pipeline { + agent any + options { + disableConcurrentBuilds() + buildDiscarder(logRotator(numToKeepStr: '10', artifactNumToKeepStr: '10')) + } + stages { + stage('Build') { + steps { + sh './gradlew clean build' + } + post { + always { + junit 'backend/build/test-results/**/*.xml' + jacoco execPattern: '**/build/jacoco/test.exec' + } + } + } + stage('Build Docker images') { + when { + expression { + return GIT_BRANCH in ['master'] + } + } + steps { + sh '''./gradlew docker + ''' + } + } + stage('Deploy') { + when { + expression { + return GIT_BRANCH in ['master'] + } + } + steps { + sh ''' + docker stop shibui || true && docker rm shibui || true + docker run -d --restart always --name shibui -p 8080:8080 -v /etc/shibui/application.properties:/application.properties unicon/shibui:latest + ''' + } + } + } + post { + failure { + step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: emailextrecipients([[$class: 'CulpritsRecipientProvider'], [$class: 'RequesterRecipientProvider']])]) + } + success { + emailext body: '''${SCRIPT, template="groovy-text.template"}''', recipientProviders: [[$class: 'DevelopersRecipientProvider'], [$class: 'RequesterRecipientProvider']], subject: '[SHIBUI] Build Success' + } + } +} \ No newline at end of file diff --git a/backend/Dockerfile b/backend/Dockerfile new file mode 100644 index 000000000..cec9c4c44 --- /dev/null +++ b/backend/Dockerfile @@ -0,0 +1,9 @@ +FROM gcr.io/distroless/java + +ARG JAR_FILE + +COPY ${JAR_FILE} app.jar + +EXPOSE 8080 + +CMD ["app.jar"] \ No newline at end of file diff --git a/backend/build.gradle b/backend/build.gradle index 2ffd807f7..167bd3994 100644 --- a/backend/build.gradle +++ b/backend/build.gradle @@ -5,6 +5,7 @@ plugins { id 'com.gorylenko.gradle-git-properties' version '1.4.21' id 'net.researchgate.release' version '2.6.0' id 'io.franzbecker.gradle-lombok' version '1.13' + id 'com.palantir.docker' version '0.20.1' } apply plugin: 'io.spring.dependency-management' @@ -206,4 +207,14 @@ jacocoTestReport { csv.enabled = false html.destination = file("${buildDir}/jacocoHtml") } +} + +tasks.docker.dependsOn tasks.build +docker { + name 'unicon/shibui' + tags 'latest' + pull true + noCache true + files tasks.bootWar.outputs + buildArgs(['JAR_FILE': 'shibui.war']) } \ No newline at end of file