From 640ccb7ef8e58b7cee8a1c0bfd73ffc2cdf045d9 Mon Sep 17 00:00:00 2001 From: Maxime Dor Date: Sun, 17 Sep 2017 15:12:39 +0200 Subject: [PATCH] Improve docker build process and doc --- README.md | 4 ++-- build.gradle | 13 +++++++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 6f3f59c..caa6437 100644 --- a/README.md +++ b/README.md @@ -80,11 +80,11 @@ For more info, see [the public repository](https://hub.docker.com/r/kamax/mxisd/ ### From source [Build mxisd](#build) then build the docker image: ``` -docker build -t your-org/mxisd:$(git describe --tags --always --dirty) . +./gradlew dockerBuild ``` You can run a container of the given image and test it with the following command (adapt volumes host paths): ``` -docker run -v /data/mxisd/etc:/etc/mxisd -v /data/mxisd/var:/var/mxisd -p 8090:8090 -t your-org/mxisd:$(git describe --tags --always --dirty) +docker run -v /data/mxisd/etc:/etc/mxisd -v /data/mxisd/var:/var/mxisd -p 8090:8090 -t kamax/mxisd:latest-dev ``` # From Source diff --git a/build.gradle b/build.gradle index 69df987..a041299 100644 --- a/build.gradle +++ b/build.gradle @@ -40,6 +40,9 @@ def debBuildConfPath = "${debBuildBasePath}${debConfPath}" def debBuildDataPath = "${debBuildBasePath}${debDataPath}" def debBuildSystemdPath = "${debBuildBasePath}${debSystemdPath}" +def dockerImageName = "kamax/mxisd" +def dockerImageTag = "${dockerImageName}:${gitVersion()}" + String gitVersion() { def versionPattern = Pattern.compile("v(\\d+\\.)?(\\d+\\.)?(\\d+)(-.*)?") ByteArrayOutputStream out = new ByteArrayOutputStream() @@ -218,9 +221,15 @@ task buildDeb(dependsOn: build) { } task dockerBuild(type: Exec, dependsOn: build) { - commandLine 'docker', 'build', '-t', "kamax/mxisd:${gitVersion()}", project.rootDir + commandLine 'docker', 'build', '-t', dockerImageTag, project.rootDir + + doLast { + exec { + commandLine 'docker', 'tag', dockerImageTag, "${dockerImageName}:latest-dev" + } + } } task dockerPush(type: Exec) { - commandLine 'docker', 'push', "kamax/mxisd:${gitVersion()}" + commandLine 'docker', 'push', dockerImageTag }