Cette image est directement compatible avec l’outil Pterodactyl.
Introduction
Il est nécessaire d’avoir installé au préalable Docker sur votre Archlinux.
Pour construire une image Docker compatible AMD64 vous aurez besoin de 8 fichiers :
- build.sh
- platform.sh
- Dockerfile
- bashrc (à placer dans le répertoire files)
- docker-java-home (à placer dans le répertoire files)
- entrypoint.sh (à placer dans le répertoire files)
Fichiers requis
platform.sh
[Fichier]
#!/bin/bash
# Used in Docker build to set platform dependent variables
case $TARGETARCH in
"amd64")
echo "x86_64-unknown-linux-gnu" > /.platform
echo "" > /.compiler
;;
"arm64")
echo "aarch64-unknown-linux-gnu" > /.platform
echo "gcc-aarch64-linux-gnu" > /.compiler
;;
"arm")
echo "armv7-unknown-linux-gnueabihf" > /.platform
echo "gcc-arm-linux-gnueabihf" > /.compiler
;;
esac
build.sh
[Fichier]
#!/bin/bash
# ----------------------------------
# Pterodactyl Core Dockerfile Builder
# Environment: Java / GraalVM
# Minimum Panel Version: 1.7.0
# ----------------------------------
# 2022-09-29
clear
cd \"\$\(dirname \"\$0\")\" \|| exit 1
# patch: docker-java-home
echo "#/bin/sh" > files/docker-java-home
echo "echo $JAVA_HOME" >> files/docker-java-home
IMAGE_BASE=zogg/graalvm
IMAGE_VERSION=${GRAAL_VERSION}
IMAGE_NAME_LATEST=${IMAGE_BASE}:latest
IMAGE_NAME_VERSION=${IMAGE_BASE}:${IMAGE_VERSION}
export DOCKER_CLI_EXPERIMENTAL=enabled
docker run --privileged --rm tonistiigi/binfmt --install all
# Authenticate to Oracle
docker login container-registry.oracle.com
docker pull container-registry.oracle.com/graalvm/enterprise:latest
export DOCKER_DEFAULT_PLATFORM=linux/amd64
docker buildx build --pull --no-cache \
--platform=linux/amd64 \
--output=type=docker \
--build-arg TZ=Europe/Paris \
--build-arg CONCURRENCY=$(nproc) \
-t "${IMAGE_NAME_LATEST}" \
. 2>&1 | tee build.log
exit 0
Dockerfile
[Fichier]
# ----------------------------------
# Pterodactyl Core Dockerfile
# Environment: Java
# Minimum Panel Version: 1.7.0
# ----------------------------------
# Copyright (c) 2021 Matthew Penner
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
# ----------------------------------
# 2022-09-23
FROM --platform=linux/amd64 container-registry.oracle.com/graalvm/enterprise:latest
ARG TARGETPLATFORM
ARG TARGETOS
ARG TARGETARCH
ARG BUILDPLATFORM
ARG BUILDOS
ARG BUILDARCH
ARG BUILDVARIANT
COPY platform.sh .
RUN ./platform.sh
CMD ["bash"]
ENV LANG C.UTF-8
ENV PATH ${JAVA_HOME}/bin:${PATH}
LABEL author "Olivier Le Bris"
LABEL maintainer "zogg"
LABEL com.centurylinklabs.watchtower.enable=false
LABEL org.opencontainers.image.source "https://zogg.fr"
LABEL org.opencontainers.image.licenses MIT
RUN set -eux && \
microdnf update -y && \
microdnf install -y curl ca-certificates p11-kit openssl tar sqlite fontconfig tzdata iproute libstdc++ bash && \
useradd -d /home/container -m container
USER container
ENV USER container
ENV HOME /home/container
WORKDIR /home/container
ENV LANG C.UTF-8
ENV PATH ${JAVA_HOME}/bin:${PATH}
COPY files/docker-java-home /usr/local/bin/docker-java-home
COPY files/bashrc /home/container/.bashrc
COPY files/entrypoint.sh /entrypoint.sh
CMD ["/bin/bash", "/entrypoint.sh"]
bashrc
[Fichier]
export PS1='\n\[\e[32m\]\u@\h: \[\e[33m\]\w\[\e[0m\]\n> '
export BASH=/bin/bash
export SHELL=$BASH
export PATH=$JAVA_HOME:$PATH
export LS_OPTIONS='--color=auto'
alias ls='ls $LS_OPTIONS'
alias ll='ls $LS_OPTIONS -l'
alias la='ls $LS_OPTIONS -la'
docker-java-home
[Fichier]
#/bin/sh
echo /opt/java/graalvm
entrypoint.sh
[Fichier]
#!/bin/bash
#
# Copyright (c) 2021 Matthew Penner
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
# Default the TZ environment variable to UTC.
TZ=${TZ:-UTC}
export TZ
# Set environment variable that holds the Internal Docker IP
INTERNAL_IP=$(ip route get 1 | awk '{print $NF;exit}')
export INTERNAL_IP
# Switch to the container's working directory
cd /home/container \|| exit 1
# Display Specifics
printf ">>> [ GraalVM AMD64 Image ] <<<\n"
# Print Java version
printf "\033[1m\033[33mcontainer@pterodactyl~ \033[0mjava -version\n"
java -version
# Convert all of the "" parts of the command into the expected shell
# variable format of "${VARIABLE}" before evaluating the string and automatically
# replacing the values.
PARSED=\$\(echo \"\${STARTUP}\" | sed -e 's/{ {/\$ {/g' -e 's/} }/ }/g' | eval echo \"\$\(cat -)\")
# Display the command we're running in the output, and then execute it with the env
# from the container itself.
printf "\033[1m\033[33mcontainer@pterodactyl~ \033[0m%s\n" "$PARSED"
# shellcheck disable=SC2086
exec env ${PARSED}
Procédure
Avant de vous lancer dans la procédure, il faut :
- Avoir un compte Oracle (obligatoire)
- Dans votre shell, vous devez vous identifier avec docker login en saisissant vos identifiants de comptes Oracle
Il peut être aussi utile d’ajouter la registry d’Oracle dans la configuration de Portainer par exemple.
Enfin, pour lancer la construction de l’image, il suffit de donner au script shell build.sh les droits d’exécution puis de le lancer :
sudo chmod +x build.sh && sudo bash build.sh
Conclusion
Vous avez maintenant une image Docker compatible AMD64 à lancer sous Docker (ou avec Portainer :p).
NB : Vous pouvez l’utiliser directement sous Pterodactyl à condition d’avoir une Registry Docker sur laquelle vous pouvez déposer l’image pour qu’elle puisse être récupérée par Pterodactyl de la même façon que les images natives.