last updated: Sun Dec 11 10:45:12 CET 2022
author: Lukasz Ochmanski (github@ochmanski.de)
Opinionated docker image based on the Debian docker image debian:stable-slim
to
build native Linux binaries from Java Gradle projects using GraalVM native-image feature.
Mandrel focuses on GraalVM's native-image component in order to provide an easy way for Quarkus users to generate native images for their applications.
Developers using Quarkus should be able to go all the way from Java source code to lean, native, platform-dependent applications running on Linux.
This capability is vital for deploying to containers in a cloud-native application development model.
As always, it is recommended to use a specific, fixed version of the software, for example use a tag 1.0.6
instead of latest
.
Semantic versioning tags are immutable and they provide reproducible builds.
Tags such as latest
or jdk17
are merely aliases pointing to some fully qualified identifier.
Fully qualified image identifiers guarantee reliable builds. These images will not change.
Please do not use floating tags in production. They are only for convenience and development purposes.
Each floating docker tag in this docker registry corresponds to the fixed tag in its own, more specific, docker registry.
Simply look up the digest of the image and find it in another repo.
This means that some images are referenced across different docker registries. This is intended.
Since a fixed version is present only in one of these registries, it should be easy to find the full path.
Always search for the most specific, therefore the longest path, with the specific semantic versioning tag.
It is discouraged to use floating tags, but I provided them for an easy and quick start.
Once you get familiar with the image, you may replace the path with the fully qualified path and the fixed tag.
Fully qualified image path is guaranteed to point to this unique digest. The image underneath will not change.
You may safely use it in your codebase. There is no reason to use image digest. Although, it will also do the job.
The following table contains links to the Dockerfile in git repository, from which the Docker image was built. Feel free to look at source by clicking the link below.
For the convenience of users I provided 6 floating tags for Java 11 and 7 floating tags for Java 17:
Java | GraalVM | Gradle | Dockerfile |
---|---|---|---|
17 | 22.2 | 7.5 | mandrel-22-2-gradle-7-5-java-17 , 22-2-gradle-7-5-java-17 , java-17 , java17 , jdk-17 , jdk17 , latest |
11 | 22.2 | 7.5 | mandrel-22-2-gradle-7-5-java-11 , 22-2-gradle-7-5-java-11 , java-11 , java11 , jdk-11 , jdk11 |
Table 1.1. Supported tags and respective Dockerfile links
REPOSITORY | TAG | IMAGE ID | SIZE |
---|---|---|---|
ochmanskide/mandrel-gradle | mandrel-22-2-gradle-7-5-java-17 | 00456ebbedab | 1.06GB |
ochmanskide/mandrel-gradle | 22-2-gradle-7-5-java-17 | 00456ebbedab | 1.06GB |
ochmanskide/mandrel-gradle | java-17 | 00456ebbedab | 1.06GB |
ochmanskide/mandrel-gradle | java17 | 00456ebbedab | 1.06GB |
ochmanskide/mandrel-gradle | jdk-17 | 00456ebbedab | 1.06GB |
ochmanskide/mandrel-gradle | jdk17 | 00456ebbedab | 1.06GB |
ochmanskide/mandrel-gradle | latest | 00456ebbedab | 1.06GB |
ochmanskide/...11-bullseye.mandrel.22-2.java.17.mandrel-22-2-gradle-7-5-java-17 |
1.0.6 | 00456ebbedab | 1.06GB |
ochmanskide/...11-bullseye.mandrel.22-2.java.17.mandrel-22-2-gradle-7-5-java-17 |
latest | 00456ebbedab | 1.06GB |
Table 1.2. Docker Repository naming conventions
as you can see from the table 2.2., the highest semantic versioning number corresponds to the floating tag latest
, and also the highest supported java version at the moment, which is 17.
In order to determine the highest semantic version for older java, for example 11 search in the docker hub registry for this specific version.
Here is an example URL:
https://hub.docker.com/repository/docker/ochmanskide/base.images.debian.11-bullseye.mandrel.22-2.java.11.mandrel-22-2-gradle-7-5-java-11
repository names are created according to the convention, so that you are able to find the right one:
https://hub.docker.com/repository/docker/ochmanskide/base.images.debian.11-bullseye.mandrel.22-2.java.11.mandrel-22-2-gradle-7-5-java-11
https://hub.docker.com/repository/docker/ochmanskide/base.images.debian.11-bullseye.mandrel.22-2.java.17.mandrel-22-2-gradle-7-5-java-17
etc.
### Mandrel Image
### Debian Slim
### Debian based Mandrel Official Image
### base/images/debian/debian-11-bullseye/mandrel/22-2/java-17/mandrel-22-2-gradle-7-5-java-17
### base.images.debian.11-bullseye.mandrel.22-2.java.17.mandrel-22-2-gradle-7-5-java-17
### ochmanskide/base.images.debian.11-bullseye.mandrel.22-2.java.17.mandrel-22-2-gradle-7-5-java-17
debian-11-bullseye/mandrel-22-2-gradle-7-5-java-17 00-slim 80MB (80MB)
debian-11-bullseye/mandrel-22-2-gradle-7-5-java-17 01-clean 80MB (0MB)
debian-11-bullseye/mandrel-22-2-gradle-7-5-java-17 02-graalvm 465MB (385MB)
debian-11-bullseye/mandrel-22-2-gradle-7-5-java-17 03-gradle 594MB (129MB)
debian-11-bullseye/mandrel-22-2-gradle-7-5-java-17 04-aws-cli 753MB (159MB)
debian-11-bullseye/mandrel-22-2-gradle-7-5-java-17 05-docker-cli 805MB (52MB)
debian-11-bullseye/mandrel-22-2-gradle-7-5-java-17 06-dockerd 870MB (65MB)
debian-11-bullseye/mandrel-22-2-gradle-7-5-java-17 07-containerd 904MB (34MB)
debian-11-bullseye/mandrel-22-2-gradle-7-5-java-17 08-build-essential
debian-11-bullseye/mandrel-22-2-gradle-7-5-java-17 09-libz-dev
debian-11-bullseye/mandrel-22-2-gradle-7-5-java-17 10-zlib1g-dev 1.11GB (196MB)
debian-11-bullseye/mandrel-22-2-gradle-7-5-java-17 11-git 1.18GB (70MB)
Debian is Non-commercial Linux Distribution, which is very much stable and contains very large number of packages into its repository.
Debian contains nearly 80% more packages than RedHat and this is the reason Debian contains packages like openoffice, Transmission bittorrent client, mp3 codecs, etc which a RedHat like distribution lacks and is required to be installed manually or from 3rd party repository.
docker pull ochmanskide/mandrel-gradle:latest
docker run -it --entrypoint /bin/bash ochmanskide/mandrel-gradle:latest
git clone https://github.com/ochmanskide/quarkus.code-with-quarkus.git /home/quarkus/code-with-quarkus
cd /home/quarkus/code-with-quarkus
gradle build -x test -Dquarkus.package.type=native
4.2.5. when the build completes, you may run the binary, which is located somewhere in /build/libs/ directory.
/home/quarkus/code-with-quarkus/build/libs/code-with-quarkus-1.0.0-SNAPSHOT-runner
Most images are based on a standard debian image: https://hub.docker.com/_/debian
FROM debian:stable-20220711-slim
git clone git@github.com:ochmanskide/base.images.debian.11-bullseye.mandrel.22-2.java.17.mandrel-22-2-gradle-7-5-java-17.git ~/Workspace/ochmanskide/base/images/debian/11-bullseye/mandrel/22-2/java/17/mandrel-22-2-gradle-7-5-java-17
Since this registry contains a collection of images, there is more than one source code:
- https://github.com/ochmanskide/base.images.debian.11-bullseye.mandrel.22-2.java.11.mandrel-22-2-gradle-7-5-java-11
- https://github.com/ochmanskide/base.images.debian.11-bullseye.mandrel.22-2.java.17.mandrel-22-2-gradle-7-5-java-17
More details available directly in the Section 3. How to build locally of README.md file.
Excerpt:
export DOCKER_HUB_HOST=$USER
cd ~/Workspace/ochmanskide/base/images/debian/11-bullseye/mandrel/22-2/java/17/mandrel-22-2-gradle-7-5-java-17
gradle docker
- https://hub.docker.com/repository/docker/ochmanskide/base.images.debian.11-bullseye.mandrel.22-2.java.11.mandrel-22-2-gradle-7-5-java-17
- https://hub.docker.com/repository/docker/ochmanskide/base.images.debian.11-bullseye.mandrel.22-2.java.11.mandrel-22-2-gradle-7-5-java-11
- https://hub.docker.com/repository/docker/ochmanskide/mandrel-gradle
- https://hub.docker.com/repository/docker/ochmanskide/graalvm-gradle
Mandrel 22.2.0.0-Final is a downstream distribution of the GraalVM community edition 22.2.0.
Mandrel's main goal is to provide a native-image release specifically to support Quarkus.
The aim is to align the native-image capabilities from GraalVM with OpenJDK and Red Hat Enterprise Linux libraries to improve maintainability for native Quarkus applications.
How Does Mandrel Differ From Graal
Mandrel releases are built from a code base derived from the upstream GraalVM code base, with only minor changes but some significant exclusions.
They support the same native image capability as GraalVM with no significant changes to functionality.
They do not include support for Polyglot programming via the Truffle interpreter and compiler framework.
In consequence, it is not possible to extend Mandrel by downloading languages from the Truffle language catalogue.
Mandrel is also built slightly differently to GraalVM, using the standard OpenJDK project release of jdk11u.
This means it does not profit from a few small enhancements that Oracle have added to the version of OpenJDK used to build their own GraalVM downloads.
Most of these enhancements are to the JVMCI module that allows the Graal compiler to be run inside OpenJDK.
The others are small cosmetic changes to behaviour.
These enhancements may in some cases cause minor differences in the progress of native image generation.
They should not cause the resulting images themselves to execute in a noticeably different manner.
Mandrel's native-image
depends on the following packages:
freetype-devel
gcc
glibc-devel
libstdc++-static
zlib-devel
On Fedora/CentOS/RHEL they can be installed with:
dnf install glibc-devel zlib-devel gcc freetype-devel libstdc++-static
Note: The package might be called
glibc-static
orlibstdc++-devel
instead oflibstdc++-static
depending on your system.
If the system is missingstdc++
,gcc-c++
package is needed too.
On Ubuntu-like systems with:
apt install g++ zlib1g-dev libfreetype6-dev
$ docker run -it --entrypoint /bin/bash ochmanskide/mandrel-gradle:latest
# echo $0
/bin/bash
# pwd
/home/gradle
# whoami
root
# cat /etc/*-release
PRETTY_NAME="Debian GNU/Linux 11 (bullseye)"
NAME="Debian GNU/Linux"
VERSION_ID="11"
VERSION="11 (bullseye)"
VERSION_CODENAME=bullseye
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
# printenv
GRAALVM_HOME=/opt/graalvm
DOCKER_HUB_URL=https://hub.docker.com/repository/docker/
DOCKER_HOST=ochmanskide
JAVA_HOME=/opt/graalvm
GRADLE_HOME=/opt/gradle
DOCKER_REPOSITORY=releases
PWD=/home/gradle
IMAGE_SOURCE=https://github.com/ochmanskide/base.images.debian.11-bullseye.mandrel.22-2.java.17.mandrel-22-2-gradle-7-5-java-17
HOME=/root
GRADLE_VERSION=7.5
TERM=xterm
HOST=ochmanskide
SHLVL=1
PATH=/opt/graalvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
DOWNLOADS=/downloads
DEBIAN_FRONTEND=noninteractive
JAVA_VERSION=17.0.3+7
_=/usr/bin/printenv
# curl --version
bash: curl: command not found
# java -version
openjdk version "17.0.3" 2022-04-19
OpenJDK Runtime Environment Temurin-17.0.3+7 (build 17.0.3+7)
OpenJDK 64-Bit Server VM Temurin-17.0.3+7 (build 17.0.3+7, mixed mode, sharing)
root@40d34d5c68df:/home/gradle#
# git version
git version 2.30.2
# docker --version
Docker version 20.10.11, build dea9396
# gradle -version
Welcome to Gradle 7.5!
Here are the highlights of this release:
- Support for Java 18
- Support for building with Groovy 4
- Much more responsive continuous builds
- Improved diagnostics for dependency resolution
For more details see https://docs.gradle.org/7.5/release-notes.html
------------------------------------------------------------
Gradle 7.5
------------------------------------------------------------
Build time: 2022-07-14 12:48:15 UTC
Revision: c7db7b958189ad2b0c1472b6fe663e6d654a5103
Kotlin: 1.6.21
Groovy: 3.0.10
Ant: Apache Ant(TM) version 1.10.11 compiled on July 10 2021
JVM: 17.0.3 (Eclipse Adoptium 17.0.3+7)
OS: Linux 5.10.25-linuxkit amd64
# aws --version
aws-cli/2.7.18 Python/3.9.11 Linux/5.10.104-linuxkit exe/x86_64.debian.11 prompt/off
# cat /home/gradle/.gradle/gradle.properties
org.gradle.daemon=true
org.gradle.parallel=true
org.gradle.caching=true
org.gradle.console=plain
# ls -la /home/gradle
drwxr-xr-x 1 root root 4096 Apr 19 10:21 .
drwxr-xr-x 1 root root 4096 Apr 13 14:57 ..
-rwxr-xr-x 1 root root 220 Apr 14 08:44 .bash_logout
-rwxr-xr-x 1 root root 3771 Apr 14 08:44 .bashrc
drwxr-xr-x 1 root root 4096 Apr 19 10:21 .gradle
-rwxr-xr-x 1 root root 807 Apr 14 08:44 .profile
docker run -it --entrypoint /bin/bash ochmanskide/mandrel-gradle
java -version && echo
gradle -version && echo
docker --version && echo
aws --version && echo
# manually start Docker daemon (which is also a default entrypoint)
/usr/local/bin/dockerd-entrypoint.sh 2> /dev/null && echo
# optional - authenticate to AWS Elastic Container Registry
# (if you had installed AWS CLI tool, from the script that I provided)
# more details available in FAQ Section 15.3.
/home/aws/ecr/login.sh && echo
# verify that Docker was connected, and list all images
docker images && echo
clone the project:
docker run -it --entrypoint /bin/bash ochmanskide/base.images.debian.11-bullseye.mandrel.22-2.java.17.mandrel-22-2-gradle-7-5-java-17
git clone https://github.com/ochmanskide/quarkus.code-with-quarkus.git /home/quarkus/code-with-quarkus
cd /home/quarkus/code-with-quarkus
build native image:
gradle build -x test -Dquarkus.package.type=native
when the build completes, you may run the image, which is located somewhere in /build/libs/ directory.
/home/quarkus/code-with-quarkus/build/libs/code-with-quarkus-1.0.0-SNAPSHOT-runner
docker run -it --entrypoint /bin/bash ochmanskide/base.images.debian.11-bullseye.mandrel.22-2.java.17.mandrel-22-2-gradle-7-5-java-17
git clone https://github.com/ochmanskide/quarkus.code-with-quarkus.git /home/quarkus/code-with-quarkus
cd /home/quarkus/code-with-quarkus/
./mvnw package -Pnative
./target/code-with-quarkus-1.0.0-SNAPSHOT-runner
Copyright 2022 Lukasz Ochmanski
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
View license information for the software contained in this image.
As with all Docker images, these likely also contain other software which may be under other licenses (such as Bash, etc from the base distribution, along with any direct or indirect dependencies of the primary software being contained).
Some additional license information which was able to be auto-detected might be found in the repo-info repository's gradle/ directory.
As for any pre-built image usage, it is the image user's responsibility to ensure that any use of this image complies with any relevant licenses for all software contained within.
https://hub.docker.com/_/gradle
https://github.com/vegardit/docker-graalvm-maven
https://hub.docker.com/r/vegardit/graalvm-maven
https://hub.docker.com/r/vegardit/graalvm-maven/tags
https://github.com/graalvm/mandrel/releases/tag/mandrel-22.2.0.0-Final
Yes, you can use this project in anyway you like. Feel free to copy, fork or do whatever you like with it.
If you have questions about licensing, feel free to email me.
if you have questions, feel free to send me an email: github@ochmanski.de
I will be happy to help you.
- yes, you could use it in the AWS environment, but you just need to install AWS-CLI.
I already prepared a shell script./scripts/install/05-install-aws-cli.sh
and10-import-rds-certificates.sh
.
Simply run it and you should be able to authenticate with all AWS resources.
As an alternative, you may re-build the image from source and invoke the script directly from theDockerfile
.
The result will be the same.