sbt / sbt-native-packager

sbt Native Packager
https://sbt-native-packager.readthedocs.io/en/stable/
BSD 2-Clause "Simplified" License
1.59k stars 439 forks source link

GraalVMNativeImagePlugin plugin fails when trying to build in docker container #1469

Closed ondramastik closed 2 years ago

ondramastik commented 2 years ago

Expected behaviour

host/graalvm-native-image:packageBin generates a native image binary

Actual behaviour

host/graalvm-native-image:packageBin fails with

[error] docker: Error response from daemon: invalid mode: /opt/graalvm

Information

My build.sbt

  lazy val host = project
    .in(file("host"))
    .enablePlugins(GraalVMNativeImagePlugin)
    .settings(
      name := "some-name",
      graalVMNativeImageGraalVersion := Some("19.3.6"),
      graalVMNativeImageOptions += "--enable-all-security-services",
      containerBuildImage := Some("ghcr.io/graalvm/graalvm-ce:19.3.6")
    )
ondramastik commented 2 years ago

When I remove this setting from build.sbt: containerBuildImage := Some("ghcr.io/graalvm/graalvm-ce:19.3.6")

and I only specify the graalVMNativeImageGraalVersion 19.3.6, outcome is the same. Plugin downloads image ghcr.io-graalvm-graalvm-ce-native-image:19.3.6 and than fails with the same error

[error] docker: Error response from daemon: invalid mode: /opt/graalvm

When I specify version 19.1.1 like in documentation, it fails with:

[info] Generating new GraalVM native-image image based on ghcr.io/graalvm/graalvm-ce:19.1.1: ghcr.io-graalvm-graalvm-ce-native-image:19.1.1
[info] Sending build context to Docker daemon  2.048kB
[info] Step 1/4 : FROM ghcr.io/graalvm/graalvm-ce:19.1.1
[error] manifest unknown
ondramastik commented 2 years ago

Looks like the problem is caused by this issue: https://stackoverflow.com/questions/50540721/docker-toolbox-error-response-from-daemon-invalid-mode-root-docker I am not really sure how would I fix the issue

The ${pwd} is going to expand to something like c:\Program Files.... That means the volume mount will get parsed as:

  • source: C (or your current drive letter, this gets processed as a named volume rather than a host path)
  • target: /Program Files/... or wherever you happen to be running this command from.
  • mount options: /root/ which is an "invalid mode" (normal options include things like ro for a read only mount)