Last active
April 28, 2024 13:22
-
-
Save clrxbl/5697d63c669e33a8a92298f273ce3b68 to your computer and use it in GitHub Desktop.
java shim
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# java shim to execute anything java within a distroless, rootless container | |
# designed for podman 4, breaks with podman 3 because of different --pull syntax | |
# https://iptables.sh | |
set -euo pipefail | |
IMAGE="gcr.io/distroless/java21:nonroot" | |
# check for podman | |
# podman runs rootless out of the box unlike docker | |
if ! command -v podman &> /dev/null | |
then | |
echo "podman could not be found" | |
exit | |
fi | |
podman run \ | |
--rm \ | |
-it \ | |
--userns=keep-id:uid=65532,gid=65532 \ | |
--network host \ | |
--pull newer \ | |
-v "$(pwd)":/app \ | |
-w /app \ | |
--entrypoint /usr/bin/java \ | |
"$IMAGE" \ | |
"$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment