Skip to content

Commit

Permalink
Add user management for alpine-based images. (#30)
Browse files Browse the repository at this point in the history
* adding user management

Signed-off-by: Marat Biryushev <[email protected]>

* change tag

Signed-off-by: Marat Biryushev <[email protected]>

* changed checking to suppotr debian, fedora like os

Signed-off-by: Marat Biryushev <[email protected]>

* change tag

Signed-off-by: Marat Biryushev <[email protected]>

* use baseimages os-release

Signed-off-by: Marat Biryushev <[email protected]>

* use baseimages os-release

Signed-off-by: Marat Biryushev <[email protected]>

* use baseimages os-release

Signed-off-by: Marat Biryushev <[email protected]>

* add baseimage checking

Signed-off-by: Marat Biryushev <[email protected]>

* add baseimage checking

Signed-off-by: Marat Biryushev <[email protected]>

* add baseimage checking

Signed-off-by: Marat Biryushev <[email protected]>

* Update src/main/groovy/jp/co/soramitsu/devops/docker/DockerPlugin.groovy

PR suggested change.

Co-authored-by: Bogdan Mingela <[email protected]>

* resolve PR notes

Signed-off-by: Marat Biryushev <[email protected]>

* set property groupCommand

Signed-off-by: Marat Biryushev <[email protected]>

* Update src/main/groovy/jp/co/soramitsu/devops/docker/DockerPlugin.groovy

Co-authored-by: Bogdan Mingela <[email protected]>

---------

Signed-off-by: Marat Biryushev <[email protected]>
Co-authored-by: Bogdan Mingela <[email protected]>
  • Loading branch information
marat-biriushev and Mingela authored Jul 26, 2023
1 parent 1ca74ec commit e62a752
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,16 @@ class DockerPlugin implements Plugin<Project> {
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
Expand Down

0 comments on commit e62a752

Please sign in to comment.