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

Cross-compilation with the JLink & Docker plugins #1494

Open
demming opened this issue Feb 8, 2022 · 0 comments
Open

Cross-compilation with the JLink & Docker plugins #1494

demming opened this issue Feb 8, 2022 · 0 comments

Comments

@demming
Copy link

demming commented Feb 8, 2022

Observed and desired behavior

Using both the JLink an the Docker plugins, when developing on a Mac machine, I'd like to get a Docker image that would run on a Linux machine on a CPU architecture determined by the JDK base image, from which JLink would cherry-pick the required modules.

Right now docker:publishLocal builds the package locally outside Docker, and then injects the resulting package into the Docker image with the JDK/JRE base image for the target platform. This works fine. And I greatly appreciate it. However, the resulting container image is typically relatively large. I'd like to minimize the target JDK/JRE. This issue had come up already in #1449.

Specifically, running moduleName / docker:publishLocal performs the JLink instructions (with a lot of missing transitive dependencies, but that's a different story that I need to investigate more thoroughly) against the local JDK given by javaHome0 in JlinkPlugin.scala#L52.

I need the JLink plugin to run inside a container against the target JDK prior to the copying stage0.

I imagine there should be a way for cross-compiling with JLink to either

  • provide the path to another local JDK (which isn't good for replication), or

  • add a pre-stage to the resulting Dockerfile that would run either

    • the entire sbt build, or
    • the JLink plugin

    against the target JDK, and then use that stage rather than the baseline image.

At least I can extract the JLink parameter values and pass them on to modified Dockerfile instructions in my build.sbt but this would get all messy with a larger CI configuration and doesn't seem ready for full build automation.

Running the entire sbt workflow inside a container would solve this issue but it would break a lot of tooling and complicate the matters, for example IntelliJ IDEA didn't support it in its 2019 versions.

If there's some simple work-around please point me in the right direction.

Information

  • sbt-native-packager: 1.9.4
  • sbt: 1.6.1
  • Build system: macOS aarch64 M1 (local) + Debian (amd64, arm32v7l, arm64v8 / aarch64) targets
  • Plugins: Docker & JLink
  • Build tool: Docker version 20.10.12
  • Target systems: macOS on aarch64 & amd64 (local) and Linux on amd64 & arm32v7l & arm64v8 (remote Docker machines)
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