Skip to content

Add other upstream architectures #254

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

Merged
merged 6 commits into from
May 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 34 additions & 7 deletions src/docker_clojure/config.clj
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
(s/coll-of ::non-blank-string :distinct true :into #{}))
(s/def ::maintainer ::non-blank-string)

(s/def ::architecture #{"amd64" "arm64v8"})
(s/def ::architecture ::non-blank-string)
(s/def ::architectures (s/coll-of ::architecture :distinct true :into #{}))

(def git-repo "https://github.com/Quantisan/docker-clojure.git")
Expand All @@ -90,17 +90,18 @@
distro type. :default key is a fallback for base images not o/w specified."
{:default #{:alpine/alpine :ubuntu/jammy :ubuntu/noble}
"debian" #{:debian-slim/bookworm-slim :debian/bookworm
:debian-slim/bullseye-slim :debian/bullseye}})
:debian-slim/bullseye-slim :debian/bullseye
:debian-slim/trixie-slim :debian/trixie}})

(def architectures
#{"amd64" "arm64v8"})
#{"amd64" "arm64v8" "ppc64le" "riscv64" "s390x"})

(def default-distros
"The default distro to use for tags that don't specify one, keyed by jdk-version.
:default is a fallback for jdk versions not o/w specified."
{8 :ubuntu/jammy
11 :ubuntu/jammy
17 :ubuntu/jammy
{8 :ubuntu/noble
11 :ubuntu/noble
17 :ubuntu/noble
:default :debian/bookworm})

(def build-tools
Expand All @@ -122,7 +123,33 @@
;; No upstream ARM alpine images available before JDK 21
{:jdk-version #(< % 21)
:architecture "arm64v8"
:distro :alpine/alpine}})
:distro :alpine/alpine}
;; Only build amd64 & arm64 architectures for alpine
{:architecture #(not (#{"amd64" "arm64v8"} %))
:distro :alpine/alpine}
;; ppc64le needs Debian Bookworm or newer
{:architecture "ppc64le"
:distro #(and (-> % namespace (str/starts-with? "debian"))
(-> % name (str/starts-with? "bullseye")))}
;; riscv64 is only supported for Java 17+
{:architecture "riscv64"
:jdk-version #(< % 17)}
;; riscv64 isn't supported on Ubuntu Jammy
{:architecture "riscv64"
:distro :ubuntu/jammy}
;; riscv64 needs Debian Trixie or newer
{:architecture "riscv64"
:distro #(and (-> % namespace (str/starts-with? "debian"))
(let [n (name %)]
(or (str/starts-with? n "bullseye")
(str/starts-with? n "bookworm"))))}
;; s390x is only supported for Java 11+
{:architecture "s390x"
:jdk-version #(< % 11)}
;; s390x needs Debian Bookworm or newer
{:architecture "s390x"
:distro #(and (-> % namespace (str/starts-with? "debian"))
(-> % name (str/starts-with? "bullseye")))}})

(def maintainers
["Paul Lam <[email protected]> (@Quantisan)"
Expand Down
22 changes: 10 additions & 12 deletions src/docker_clojure/variant.clj
Original file line number Diff line number Diff line change
Expand Up @@ -183,15 +183,13 @@
:ret (s/coll-of ::manifest-variant)
:fn #(let [ret-count (-> % :ret count)
arg-variants (-> % :args :variants)
should-merge? (fn [v]
(some (partial equal-except-architecture? v)
arg-variants))
one-per-arch (fn [c] (if (> c 0)
(/ c (count cfg/architectures))
c))
num-should-merge (->> arg-variants
(filter should-merge?)
count
one-per-arch)
arg-count (- (count arg-variants) num-should-merge)]
(= ret-count arg-count)))
;; Examine the return value to see how many unique variants we have
;; after merging all architectures
variant-keys (-> arg-variants first keys set
(disj :architecture))
unique-variants (->> arg-variants
(map (fn [v] (select-keys v variant-keys)))
set count)]
;; We expect to have one merged variant for each unique combination of keys
;; other than architecture
(= ret-count unique-variants)))
45 changes: 45 additions & 0 deletions target/debian-trixie-11/lein/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
FROM debian:trixie

ENV JAVA_HOME=/opt/java/openjdk
COPY --from=eclipse-temurin:11 $JAVA_HOME $JAVA_HOME
ENV PATH="${JAVA_HOME}/bin:${PATH}"

ENV LEIN_VERSION=2.11.2
ENV LEIN_INSTALL=/usr/local/bin/

WORKDIR /tmp

# Download the whole repo as an archive
RUN set -eux; \
apt-get update && \
apt-get install -y make git gnupg wget && \
rm -rf /var/lib/apt/lists/* && \
mkdir -p $LEIN_INSTALL && \
wget -q https://codeberg.org/leiningen/leiningen/raw/tag/$LEIN_VERSION/bin/lein-pkg && \
echo "Comparing lein-pkg checksum ..." && \
sha256sum lein-pkg && \
echo "28a1a62668c5f427b413a8677e376affaa995f023b1fcd06e2d4c98ac1df5f3e *lein-pkg" | sha256sum -c - && \
mv lein-pkg $LEIN_INSTALL/lein && \
chmod 0755 $LEIN_INSTALL/lein && \
export GNUPGHOME="$(mktemp -d)" && \
export FILENAME_EXT=jar && \
gpg --batch --keyserver hkps://keyserver.ubuntu.com --recv-keys 9D13D9426A0814B3373CF5E3D8A8243577A7859F && \
wget -q https://codeberg.org/leiningen/leiningen/releases/download/$LEIN_VERSION/leiningen-$LEIN_VERSION-standalone.$FILENAME_EXT && \
wget -q https://codeberg.org/leiningen/leiningen/releases/download/$LEIN_VERSION/leiningen-$LEIN_VERSION-standalone.$FILENAME_EXT.asc && \
echo "Verifying file PGP signature..." && \
gpg --batch --verify leiningen-$LEIN_VERSION-standalone.$FILENAME_EXT.asc leiningen-$LEIN_VERSION-standalone.$FILENAME_EXT && \
gpgconf --kill all && \
rm -rf "$GNUPGHOME" leiningen-$LEIN_VERSION-standalone.$FILENAME_EXT.asc && \
mkdir -p /usr/share/java && \
mkdir -p /root/.lein && \
mv leiningen-$LEIN_VERSION-standalone.$FILENAME_EXT /usr/share/java/leiningen-$LEIN_VERSION-standalone.jar && \
apt-get purge -y --auto-remove gnupg wget

ENV PATH=$PATH:$LEIN_INSTALL
ENV LEIN_ROOT 1

# Install clojure 1.12.0 so users don't have to download it every time
RUN echo '(defproject dummy "" :dependencies [[org.clojure/clojure "1.12.0"]])' > project.clj \
&& lein deps && rm project.clj

CMD ["lein", "repl"]
21 changes: 21 additions & 0 deletions target/debian-trixie-11/lein/entrypoint
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env bash

set -eou pipefail

entrypoint=lein

cmd=${1:-}

# check if the first arg starts with a hyphen
if [ "$#" -eq 0 ] || [ "${1#-}" != "$1" ]; then
exec "${entrypoint}" "$@"
fi

if [[ -n "${cmd}" ]]; then
# see if help for the subcommand is successful
if "${entrypoint}" "${cmd}" --help >/dev/null 2>&1; then
exec "${entrypoint}" "$@"
fi
fi

exec "$@"
29 changes: 29 additions & 0 deletions target/debian-trixie-11/tools-deps/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
FROM debian:trixie

ENV JAVA_HOME=/opt/java/openjdk
COPY --from=eclipse-temurin:11 $JAVA_HOME $JAVA_HOME
ENV PATH="${JAVA_HOME}/bin:${PATH}"

ENV CLOJURE_VERSION=1.12.0.1530

WORKDIR /tmp

RUN \
apt-get update && \
apt-get install -y curl make git rlwrap && \
rm -rf /var/lib/apt/lists/* && \
curl -fsSLO https://download.clojure.org/install/linux-install-$CLOJURE_VERSION.sh && \
sha256sum linux-install-$CLOJURE_VERSION.sh && \
echo "2a113e3a4f1005e05f4d6a6dee24ca317b0115cdd7e6ca6155a76f5ffa5ba35b *linux-install-$CLOJURE_VERSION.sh" | sha256sum -c - && \
chmod +x linux-install-$CLOJURE_VERSION.sh && \
./linux-install-$CLOJURE_VERSION.sh && \
rm linux-install-$CLOJURE_VERSION.sh && \
clojure -e "(clojure-version)" && \
apt-get purge -y --auto-remove curl

# Docker bug makes rlwrap crash w/o short sleep first
# Bug: https://github.com/moby/moby/issues/28009
# As of 2021-09-10 this bug still exists, despite that issue being closed
COPY rlwrap.retry /usr/local/bin/rlwrap

CMD ["clj"]
21 changes: 21 additions & 0 deletions target/debian-trixie-11/tools-deps/entrypoint
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env bash

set -eou pipefail

entrypoint=clj

cmd=${1:-}

# check if the first arg starts with a hyphen
if [ "$#" -eq 0 ] || [ "${1#-}" != "$1" ]; then
exec "${entrypoint}" "$@"
fi

if [[ -n "${cmd}" ]]; then
# see if help for the subcommand is successful
if "${entrypoint}" "${cmd}" --help >/dev/null 2>&1; then
exec "${entrypoint}" "$@"
fi
fi

exec "$@"
30 changes: 30 additions & 0 deletions target/debian-trixie-11/tools-deps/rlwrap.retry
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/sh

# This script works around a Docker bug that prevents rlwrap from starting
# right when a container is first started. It is intended to replace
# /usr/bin/rlwrap and also be named rlwrap but earlier in the PATH
# (e.g. /usr/local/bin).

max_tries=100 # 100 tries is ~1 second
try=0

while true; do
# see if rlwrap can start at all
output=$(/usr/bin/rlwrap true 2>&1 >/dev/null)
exit_code=$?
if [ $exit_code -gt 0 ]; then
# it didn't start
try=$((try+1))
if [ $try -gt $max_tries ]; then
# we're at max attempts so output the error and exit w/ the same code
echo "$output" >&2
exit $exit_code
else
# wait a bit and try again
sleep 0.01
fi
else
# rlwrap can start so let's run it for real
exec /usr/bin/rlwrap "$@"
fi
done
48 changes: 48 additions & 0 deletions target/debian-trixie-17/lein/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
FROM debian:trixie

ENV JAVA_HOME=/opt/java/openjdk
COPY --from=eclipse-temurin:17 $JAVA_HOME $JAVA_HOME
ENV PATH="${JAVA_HOME}/bin:${PATH}"

ENV LEIN_VERSION=2.11.2
ENV LEIN_INSTALL=/usr/local/bin/

WORKDIR /tmp

# Download the whole repo as an archive
RUN set -eux; \
apt-get update && \
apt-get install -y make git gnupg wget && \
rm -rf /var/lib/apt/lists/* && \
mkdir -p $LEIN_INSTALL && \
wget -q https://codeberg.org/leiningen/leiningen/raw/tag/$LEIN_VERSION/bin/lein-pkg && \
echo "Comparing lein-pkg checksum ..." && \
sha256sum lein-pkg && \
echo "28a1a62668c5f427b413a8677e376affaa995f023b1fcd06e2d4c98ac1df5f3e *lein-pkg" | sha256sum -c - && \
mv lein-pkg $LEIN_INSTALL/lein && \
chmod 0755 $LEIN_INSTALL/lein && \
export GNUPGHOME="$(mktemp -d)" && \
export FILENAME_EXT=jar && \
gpg --batch --keyserver hkps://keyserver.ubuntu.com --recv-keys 9D13D9426A0814B3373CF5E3D8A8243577A7859F && \
wget -q https://codeberg.org/leiningen/leiningen/releases/download/$LEIN_VERSION/leiningen-$LEIN_VERSION-standalone.$FILENAME_EXT && \
wget -q https://codeberg.org/leiningen/leiningen/releases/download/$LEIN_VERSION/leiningen-$LEIN_VERSION-standalone.$FILENAME_EXT.asc && \
echo "Verifying file PGP signature..." && \
gpg --batch --verify leiningen-$LEIN_VERSION-standalone.$FILENAME_EXT.asc leiningen-$LEIN_VERSION-standalone.$FILENAME_EXT && \
gpgconf --kill all && \
rm -rf "$GNUPGHOME" leiningen-$LEIN_VERSION-standalone.$FILENAME_EXT.asc && \
mkdir -p /usr/share/java && \
mkdir -p /root/.lein && \
mv leiningen-$LEIN_VERSION-standalone.$FILENAME_EXT /usr/share/java/leiningen-$LEIN_VERSION-standalone.jar && \
apt-get purge -y --auto-remove gnupg wget

ENV PATH=$PATH:$LEIN_INSTALL
ENV LEIN_ROOT 1

# Install clojure 1.12.0 so users don't have to download it every time
RUN echo '(defproject dummy "" :dependencies [[org.clojure/clojure "1.12.0"]])' > project.clj \
&& lein deps && rm project.clj

COPY entrypoint /usr/local/bin/entrypoint

ENTRYPOINT ["entrypoint"]
CMD ["repl"]
21 changes: 21 additions & 0 deletions target/debian-trixie-17/lein/entrypoint
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env bash

set -eou pipefail

entrypoint=lein

cmd=${1:-}

# check if the first arg starts with a hyphen
if [ "$#" -eq 0 ] || [ "${1#-}" != "$1" ]; then
exec "${entrypoint}" "$@"
fi

if [[ -n "${cmd}" ]]; then
# see if help for the subcommand is successful
if "${entrypoint}" "${cmd}" --help >/dev/null 2>&1; then
exec "${entrypoint}" "$@"
fi
fi

exec "$@"
32 changes: 32 additions & 0 deletions target/debian-trixie-17/tools-deps/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
FROM debian:trixie

ENV JAVA_HOME=/opt/java/openjdk
COPY --from=eclipse-temurin:17 $JAVA_HOME $JAVA_HOME
ENV PATH="${JAVA_HOME}/bin:${PATH}"

ENV CLOJURE_VERSION=1.12.0.1530

WORKDIR /tmp

RUN \
apt-get update && \
apt-get install -y curl make git rlwrap && \
rm -rf /var/lib/apt/lists/* && \
curl -fsSLO https://download.clojure.org/install/linux-install-$CLOJURE_VERSION.sh && \
sha256sum linux-install-$CLOJURE_VERSION.sh && \
echo "2a113e3a4f1005e05f4d6a6dee24ca317b0115cdd7e6ca6155a76f5ffa5ba35b *linux-install-$CLOJURE_VERSION.sh" | sha256sum -c - && \
chmod +x linux-install-$CLOJURE_VERSION.sh && \
./linux-install-$CLOJURE_VERSION.sh && \
rm linux-install-$CLOJURE_VERSION.sh && \
clojure -e "(clojure-version)" && \
apt-get purge -y --auto-remove curl

# Docker bug makes rlwrap crash w/o short sleep first
# Bug: https://github.com/moby/moby/issues/28009
# As of 2021-09-10 this bug still exists, despite that issue being closed
COPY rlwrap.retry /usr/local/bin/rlwrap

COPY entrypoint /usr/local/bin/entrypoint

ENTRYPOINT ["entrypoint"]
CMD ["-M", "--repl"]
21 changes: 21 additions & 0 deletions target/debian-trixie-17/tools-deps/entrypoint
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env bash

set -eou pipefail

entrypoint=clj

cmd=${1:-}

# check if the first arg starts with a hyphen
if [ "$#" -eq 0 ] || [ "${1#-}" != "$1" ]; then
exec "${entrypoint}" "$@"
fi

if [[ -n "${cmd}" ]]; then
# see if help for the subcommand is successful
if "${entrypoint}" "${cmd}" --help >/dev/null 2>&1; then
exec "${entrypoint}" "$@"
fi
fi

exec "$@"
Loading
Loading