Skip to content

Commit

Permalink
[DOPS-2632] Add a command to install tini in alpine image (#31)
Browse files Browse the repository at this point in the history
* [DOPS-2632] Add a command to install tini in alpine image

* [DOPS-2632] Add a command to install tini in alpine image

* [DOPS-2632] Add a command to install tini in alpine image

* [DOPS-2632] Add a command to install tini in alpine image
  • Loading branch information
baotn166 authored Jul 31, 2023
1 parent e62a752 commit 917103d
Showing 1 changed file with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -209,22 +209,22 @@ class DockerPlugin implements Plugin<Project> {
// copy jar
t.copyFile jar.name, "/${jar.name}"

// setup tiny https://github.com/krallin/tini
t.addFile "https://github.com/krallin/tini/releases/download/v0.19.0/tini", "/tini"
t.runCommand "chmod +x /tini"
t.entryPoint "/tini", "--"

// add user
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"
// setup tiny https://github.com/krallin/tini
t.runCommand "apk add --no-cache tini"
t.runCommand "addgroup -S appuser && adduser -S -G appuser appuser"
} else {
groupCommand = "groupadd -r appuser && useradd -r -g appuser appuser"
// setup tiny https://github.com/krallin/tini
t.addFile "https://github.com/krallin/tini/releases/download/v0.19.0/tini", "/sbin/tini"
t.runCommand "chmod +x /sbin/tini"
t.runCommand "groupadd -r appuser && useradd -r -g appuser appuser"
}
t.runCommand groupCommand
t.entryPoint "tini", "--"
t.instruction "USER appuser"

// if null, then use empty string
Expand Down

0 comments on commit 917103d

Please sign in to comment.