official-images icon indicating copy to clipboard operation
official-images copied to clipboard

Add graalvm image

Open cap10morgan opened this issue 4 years ago • 17 comments

This adds a GraalVM image for building native executables from JVM-based languages. Their license permits redistribution of the community edition, which is what this is packaging up.

I asked if the upstream packagers could publish their Docker images as official images, but they don't seem receptive to that idea. I am already one of the maintainers of the official clojure image, so I'm happy to take this on too. I need it at work anyway.

Checklist for Review

NOTE: This checklist is intended for the use of the Official Images maintainers both to track the status of your PR and to help inform you and others of where we're at. As such, please leave the "checking" of items to the repository maintainers. If there is a point below for which you would like to provide additional information or note completion, please do so by commenting on the PR. Thanks! (and thanks for staying patient with us :heart:)

  • [ ] associated with or contacted upstream?
  • [ ] does it fit into one of the common categories? ("service", "language stack", "base distribution")
  • [ ] is it reasonably popular, or does it solve a particular use case well?
  • [ ] does a documentation PR exist? (should be reviewed and merged at roughly the same time so that we don't have an empty image page on the Hub for very long)
  • [ ] official-images maintainer dockerization review for best practices and cache gotchas/improvements (ala the official review guidelines)?
  • [ ] 2+ official-images maintainer dockerization review?
  • [ ] existing official images have been considered as a base? (ie, if foobar needs Node.js, has FROM node:... instead of grabbing node via other means been considered?)
  • [ ] if FROM scratch, tarballs only exist in a single commit within the associated history?
  • [ ] passes current tests? any simple new tests that might be appropriate to add? (https://github.com/docker-library/official-images/tree/master/test)

cap10morgan avatar Sep 21 '21 17:09 cap10morgan

Diff for 19a8f909b1e4cc3e62a965d4e1eb4136358bf307:
diff --git a/_bashbrew-cat b/_bashbrew-cat
index bdfae4a..c9073e5 100644
--- a/_bashbrew-cat
+++ b/_bashbrew-cat
@@ -1 +1,7 @@
-Maintainers: New Image! :D (@docker-library-bot)
+Maintainers: Wes Morgan <[email protected]> (@cap10morgan)
+Architectures: amd64, arm64v8
+GitRepo: https://github.com/fluree/docker-graalvm.git
+GitCommit: db3aebbe6ea98642f6275b1eb30da5025a81f791
+
+Tags: latest, bullseye-slim, 21.2.0, 21.2, 21, 21-bullseye-slim, 21.2-bullseye-slim, 21.2.0-bullseye-slim
+Directory: bullseye-slim
diff --git a/_bashbrew-list b/_bashbrew-list
index e69de29..665b4c3 100644
--- a/_bashbrew-list
+++ b/_bashbrew-list
@@ -0,0 +1,8 @@
+graalvm:21
+graalvm:21-bullseye-slim
+graalvm:21.2
+graalvm:21.2-bullseye-slim
+graalvm:21.2.0
+graalvm:21.2.0-bullseye-slim
+graalvm:bullseye-slim
+graalvm:latest
diff --git a/graalvm_21.2.0-bullseye-slim/Dockerfile b/graalvm_21.2.0-bullseye-slim/Dockerfile
new file mode 100644
index 0000000..55f4b4f
--- /dev/null
+++ b/graalvm_21.2.0-bullseye-slim/Dockerfile
@@ -0,0 +1,48 @@
+FROM debian:bullseye-slim
+
+ARG GRAALVM_VERSION=21.2.0
+ARG JAVA_VERSION=11
+ARG GRAALVM_PKG=graalvm-ce-java${JAVA_VERSION}-linux-GRAALVM_ARCH-${GRAALVM_VERSION}.tar.gz
+ARG GRAALVM_URL_ROOT=https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-${GRAALVM_VERSION}/
+ARG TARGETPLATFORM
+
+RUN set -eux; \
+    apt-get update; \
+    apt-get install -y --no-install-recommends \
+    ca-certificates p11-kit \
+    curl \
+    ; \
+    rm -rf /var/lib/apt/lists/*
+
+ENV LANG=en_US.UTF-8 \
+    JAVA_HOME=/opt/graalvm-ce-java${JAVA_VERSION}-${GRAALVM_VERSION}/
+
+COPY gu-wrapper.sh /usr/local/bin/gu
+
+ENV GRAALVM_AMD64_SHA256=bbd3e03025168172a76c2a29e6a14c1c37e3476b30774259c3ef5952fb86f470
+ENV GRAALVM_ARM64_SHA256=bbdf38d5e6871f7e3b2470ab9b9bb760667d4524ee2a20eadfaf13636a2d018c
+
+RUN set -eux; \
+    dpkgArch="$(dpkg --print-architecture)"; \
+    GRAALVM_PKG=$(printf '%s\n' "$GRAALVM_PKG" | sed "s/GRAALVM_ARCH/${dpkgArch}/"); \
+    curl --fail --silent --location --retry 3 --remote-name ${GRAALVM_URL_ROOT}${GRAALVM_PKG}; \
+    if [ "$dpkgArch" = "amd64" ]; then \
+      echo "$GRAALVM_AMD64_SHA256 *${GRAALVM_PKG}" | sha256sum --strict --check; \
+    fi; \
+    if [ "$dpkgArch" = "arm64" ]; then \
+      echo "$GRAALVM_ARM64_SHA256 *${GRAALVM_PKG}" | sha256sum --strict --check; \
+    fi; \
+    tar -xzC /opt/ -f ${GRAALVM_PKG}; \
+    mkdir -p "/usr/java"; \
+    ln -sfT "$JAVA_HOME" /usr/java/default; \
+    ln -sfT "$JAVA_HOME" /usr/java/latest; \
+    for bin in "${JAVA_HOME}/bin/"*; do \
+      base="$(basename "$bin")"; \
+      [ ! -e "/usr/bin/$base" ]; \
+      update-alternatives --install "/usr/bin/$base" "$base" "$bin" 20000; \
+    done; \
+    chmod +x /usr/local/bin/gu
+
+RUN gu install native-image
+
+CMD ["jshell"]
diff --git a/graalvm_21.2.0-bullseye-slim/gu-wrapper.sh b/graalvm_21.2.0-bullseye-slim/gu-wrapper.sh
new file mode 100644
index 0000000..bb12f29
--- /dev/null
+++ b/graalvm_21.2.0-bullseye-slim/gu-wrapper.sh
@@ -0,0 +1,30 @@
+#!/usr/bin/env bash
+#
+# LICENSE UPL 1.0
+#
+# Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
+#
+
+$JAVA_HOME/bin/gu "${@}"
+RT=$?
+if [ $RT -ne 0 ]; then
+  exit $RT
+fi
+
+# Only run on *install operations
+if [[ "$@" == *"install"* ]]; then
+
+  # Add new links for newly installed components
+  for bin in "$JAVA_HOME/bin/"*; do
+    base="$(basename "$bin")";
+    if [[ ! -e "/usr/bin/$base" ]]; then
+      update-alternatives --install "/usr/bin/$base" "$base" "$bin" 20000;
+    fi
+  done;
+
+  # Remove dead links from uninstalled components
+  find /usr/bin -xtype l -delete
+
+  echo "Refreshed alternative links in /usr/bin/"
+fi
+

github-actions[bot] avatar Sep 21 '21 17:09 github-actions[bot]

Reading https://github.com/graalvm/container/issues/21, they don't sound very interested in being part of our program -- unfortunately, them not wanting this to move forward is going to be a blocker for us (the last thing we want to do is misrepresent their project).

tianon avatar Sep 21 '21 19:09 tianon

@tianon I'm not sure they don't want anyone to do it. It just sounded like they themselves had no plans to do it. I can open a new issue to ask if they are OK with me doing this, though.

cap10morgan avatar Sep 21 '21 19:09 cap10morgan

Is there a reason why you created a different Dockerfile instead of using one of the official ones from https://github.com/graalvm/container? If this is supposed to be the Docker Hub official image, it should be at least structually identical to the actual official image.

Djelibeybi avatar Sep 28 '21 22:09 Djelibeybi

@Djelibeybi Because they said they were uninterested in making that a Docker Official Image, and if I'm going to maintain it, I'd rather it be Debian-based.

However, if using that Dockerfile gets upstream's blessing to make this an official image, I'll do it. Is that something you can help with?

cap10morgan avatar Sep 28 '21 22:09 cap10morgan

I've sent an email to the GraalVM team for more info so I can understand their reasoning. Once I've got that info, I'll be able to better determine whether or not an official supported-by-Oracle image is possible.

Djelibeybi avatar Sep 28 '21 22:09 Djelibeybi

@Djelibeybi Awesome, thank you!

cap10morgan avatar Sep 28 '21 22:09 cap10morgan

@cap10morgan sure, my pleasure.

Djelibeybi avatar Sep 28 '21 22:09 Djelibeybi

@Djelibeybi Any updates from the GraalVM team?

cap10morgan avatar Oct 14 '21 18:10 cap10morgan

Nope. I'll ping thenm again.

Djelibeybi avatar Oct 14 '21 19:10 Djelibeybi

I've found a new person to ping, which I've just done.

Djelibeybi avatar Nov 02 '21 20:11 Djelibeybi

I haven't forgotten about this PR. I am going higher up the org chart.

Djelibeybi avatar Nov 17 '21 21:11 Djelibeybi

I haven't forgotten about this PR. I am going higher up the org chart.

Thank you @Djelibeybi! I keep running into use cases for a clojure+graalvm image that I've haven't pursued just b/c I didn't have time to build the hybrid image. If this existed though... :)

cap10morgan avatar Nov 17 '21 21:11 cap10morgan

Sorry for the long delay in responding. Unfortunately, it looks like the GraalVM team is not currently able to support the creation of an official GraalVM image on Docker Hub.

Djelibeybi avatar Mar 10 '22 18:03 Djelibeybi

Sorry for the long delay in responding. Unfortunately, it looks like the GraalVM team is not currently able to support the creation of an official GraalVM image on Docker Hub.

OK, yeah, that is unfortunate. Is there anything we in the community can do to help change that?

Also: Thanks for looking into this either way, @Djelibeybi!

cap10morgan avatar Mar 10 '22 18:03 cap10morgan

The only thing I can recommend is opening an issue in the GraalVM org/repo and getting as much community support as possible.

Djelibeybi avatar Mar 10 '22 18:03 Djelibeybi

The only thing I can recommend is opening an issue in the GraalVM org/repo and getting as much community support as possible.

I have this opened up over there: https://github.com/graalvm/container/issues/22

I'll see if I can drum up some community activity and support around it. Thanks!

cap10morgan avatar Mar 10 '22 18:03 cap10morgan

Sadly the GraalVM folks have shot this down for the foreseeable future. So I'll go ahead and close this.

cap10morgan avatar Jan 04 '23 16:01 cap10morgan