From ca42961131422ba753eeb9facdddef496132627f Mon Sep 17 00:00:00 2001 From: Sebastian Sdorra Date: Wed, 23 Dec 2020 10:21:14 +0100 Subject: [PATCH] Migrate docker module --- scm-packaging/docker/build.gradle | 95 +++++++++++++++++++++++++++++++ settings.gradle | 1 + 2 files changed, 96 insertions(+) create mode 100644 scm-packaging/docker/build.gradle diff --git a/scm-packaging/docker/build.gradle b/scm-packaging/docker/build.gradle new file mode 100644 index 0000000000..23a5ab5f80 --- /dev/null +++ b/scm-packaging/docker/build.gradle @@ -0,0 +1,95 @@ +/* + * MIT License + * + * Copyright (c) 2020-present Cloudogu GmbH and Contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +plugins { + id 'com.bmuschko.docker-remote-api' version '6.6.1' +} + +import org.gradle.util.VersionNumber +import com.bmuschko.gradle.docker.tasks.image.* + + +configurations { + server + webapp +} + +dependencies { + server project(':scm-server') + webapp project(path: ':scm-webapp', configuration: 'webapp') +} + +task context(type: Copy) { + VersionNumber version = VersionNumber.parse(project.version) + destinationDir = project.buildDir + into('docker') { + into('etc') { + from('src/main/fs/etc') + expand([version: version]) + } + into('opt') { + from('src/main/fs/opt') + } + into('opt/scm-server/lib') { + from project.configurations.server + } + into('opt/scm-server/var/webapp') { + from project.configurations.webapp + rename { + 'scm-webapp.war' + } + } + from('.') { + include 'Dockerfile' + } + } +} + +task distribution(type: DockerBuildImage) { + inputDir = file('build/docker') + images = images() + dependsOn 'context' +} + +def images() { + def version = project.version + if (version.contains('-SNAPSHOT')) { + String snapshotVersion = revision + def buildNumber = System.getenv("BUILD_NUMBER") + if (buildNumber != null) { + snapshotVersion += "-${buildNumber}" + } + version = version.replace("SNAPSHOT", snapshotVersion) + return [ + "docker.io/cloudogu/scm-manager:${version}" + ] + } else { + // What about patch releases? + // It is a good idea to push always latest + return [ + "docker.io/scmmanager/scm-manager:${version}", + 'docker.io/scmmanager/scm-manager:latest' + ] + } +} diff --git a/settings.gradle b/settings.gradle index 9b16c78211..fdaa56e6b5 100644 --- a/settings.gradle +++ b/settings.gradle @@ -42,5 +42,6 @@ include 'scm-packaging:unix' include 'scm-packaging:windows' include 'scm-packaging:deb' include 'scm-packaging:rpm' +include 'scm-packaging:docker' includeBuild '../gradle-smp-plugin'