Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docker:publish fails if the given daemonGroupGid does not exists #1218

Closed
NicolasRouquette opened this issue May 1, 2019 · 1 comment
Closed

Comments

@NicolasRouquette
Copy link
Contributor

Expected behaviour

sbt docker:publishLocal publishes a docker image without errors

Actual behaviour

sbt docker:publishLocal produces an error with the following variation
of src/sbt-test/docker/file-permission/changes/strategy-none.sbt:

import com.typesafe.sbt.packager.docker._

dockerPermissionStrategy := DockerPermissionStrategy.None
dockerBaseImage          := "fabric8/java-centos-openjdk8-jdk"

daemonGroupGid in Docker := Some("5000")
daemonGroup in Docker    := "sbt"

The generated Dockerfile is:

FROM fabric8/java-centos-openjdk8-jdk
USER root
RUN id -u demiourgos728 2> /dev/null || useradd --system --create-home --uid 1001 --gid 5000 demiourgos728
WORKDIR /opt/docker
COPY opt /opt
USER 1001
ENTRYPOINT ["/opt/docker/bin/file-permission-test"]
CMD []

Building this image fails:

sbt:file-permission-test> docker:publishLocal
[info] Wrote /opt/local/imce/github.sbt/sbt-native-packager/src/sbt-test/docker/file-permission/target/scala-2.12/file-permission-test_2.12-0.1.0.pom
[info] Main Scala API documentation to /opt/local/imce/github.sbt/sbt-native-packager/src/sbt-test/docker/file-permission/target/scala-2.12/api...
model contains 3 documentable templates
[info] Main Scala API documentation successful.
[info] Packaging /opt/local/imce/github.sbt/sbt-native-packager/src/sbt-test/docker/file-permission/target/scala-2.12/file-permission-test_2.12-0.1.0-javadoc.jar ...
[info] Done packaging.
[warn] [1] There are no exposed ports for your docker image
[warn]  Configure the `dockerExposedPorts` or `dockerExposedUdpPorts` setting. E.g.
[warn] 
[warn]  // standard tcp ports
[warn]  dockerExposedPorts ++= Seq(9000, 9001)
[warn] 
[warn]  // for udp ports
[warn]  dockerExposedUdpPorts += 4444
[warn]           
[success] All package validations passed
[info] Sending build context to Docker daemon  5.302MB
[info] Step 1/8 : FROM fabric8/java-centos-openjdk8-jdk
[info]  ---> 72d5b402f7da
[info] Step 2/8 : USER root
[info]  ---> Using cache
[info]  ---> 43d1a14c483e
[info] Step 3/8 : RUN id -u demiourgos728 2> /dev/null || useradd --system --create-home --uid 1001 --gid 5000 demiourgos728
[info]  ---> Running in d44d871df1fd
[info] useradd: group '5000' does not exist
[info] Removing intermediate container d44d871df1fd
[error] The command '/bin/sh -c id -u demiourgos728 2> /dev/null || useradd --system --create-home --uid 1001 --gid 5000 demiourgos728' returned a non-zero code: 6
[error] java.lang.RuntimeException: Nonzero exit value: 6
[error]         at com.typesafe.sbt.packager.docker.DockerPlugin$.publishLocalDocker(DockerPlugin.scala:483)
[error]         at com.typesafe.sbt.packager.docker.DockerPlugin$.$anonfun$projectSettings$33(DockerPlugin.scala:187)
[error]         at com.typesafe.sbt.packager.docker.DockerPlugin$.$anonfun$projectSettings$33$adapted(DockerPlugin.scala:185)
[error]         at scala.Function1.$anonfun$compose$1(Function1.scala:44)
[error]         at sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:40)
[error]         at sbt.std.Transform$$anon$4.work(System.scala:67)
[error]         at sbt.Execute.$anonfun$submit$2(Execute.scala:269)
[error]         at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:16)
[error]         at sbt.Execute.work(Execute.scala:278)
[error]         at sbt.Execute.$anonfun$submit$1(Execute.scala:269)
[error]         at sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:178)
[error]         at sbt.CompletionService$$anon$2.call(CompletionService.scala:37)
[error]         at java.util.concurrent.FutureTask.run(FutureTask.java:266)
[error]         at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
[error]         at java.util.concurrent.FutureTask.run(FutureTask.java:266)
[error]         at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
[error]         at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
[error]         at java.lang.Thread.run(Thread.java:748)
[error] (Docker / publishLocal) Nonzero exit value: 6
[error] Total time: 2 s, completed May 1, 2019 8:42:40 AM
sbt:file-permission-test> 

Information

  • What sbt-native-packager are you using
    1.3.20+2-6dced638
  • What sbt version
    1.2.8
  • What is your build system (e.g. Ubuntu, MacOS, Windows, Debian )
    Ubuntu
  • What package are you building (e.g. docker, rpm, ...)
    docker
  • What version has your build tool (find out with e.g. rpm --version)
    Docker version 18.09.2, build 6247962
  • What is your target system (e.g. Ubuntu 16.04, CentOS 7)
    fabric8/java-centos-openjdk8-jdk
@NicolasRouquette
Copy link
Contributor Author

The bug fix is incomplete in that if a daemonGroupGid is given in addition to daemonUserUid, then the plugin emits the following in the Dockerfile:

RUN <daemonUserUid>

Instead, we should get:

RUN <daemonUserId>:<daemonGroupGid>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants