diff --git a/build.gradle b/build.gradle index 696b477..b7c4259 100644 --- a/build.gradle +++ b/build.gradle @@ -13,7 +13,7 @@ plugins { group 'jp.co.soramitsu' def pluginId = "${group}.sora-plugin" -version System.getenv('TAG_NAME') ?: "0.5.3" +version System.getenv('TAG_NAME') ?: "0.5.4" repositories { mavenCentral() diff --git a/src/main/groovy/jp/co/soramitsu/devops/docker/DockerPlugin.groovy b/src/main/groovy/jp/co/soramitsu/devops/docker/DockerPlugin.groovy index c0214f0..b26d672 100644 --- a/src/main/groovy/jp/co/soramitsu/devops/docker/DockerPlugin.groovy +++ b/src/main/groovy/jp/co/soramitsu/devops/docker/DockerPlugin.groovy @@ -215,7 +215,16 @@ class DockerPlugin implements Plugin { t.entryPoint "/tini", "--" // add user - t.runCommand "groupadd -r appuser && useradd -r -g appuser appuser" + def command = "docker run -t --rm ${dockerConfig.baseImage} cat /etc/os-release" + def content = ["sh", "-c", command].execute().text + + def groupCommand = "" + if (content.contains("alpine")) { + groupCommand = "addgroup -S appuser && adduser -S -G appuser appuser" + } else { + groupCommand = "groupadd -r appuser && useradd -r -g appuser appuser" + } + t.runCommand groupCommand t.instruction "USER appuser" // if null, then use empty string