Skip to content

Commit 28a3175

Browse files
authored
Merge pull request #220 from alexander-yakushev/jdk-22
JDK 22, take two
2 parents b5c133d + f61ef22 commit 28a3175

33 files changed

Lines changed: 919 additions & 31 deletions

File tree

README.md

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,12 @@ release every 2-3 years. As of 2019-9-25, our images will default to the latest
4545
LTS release of OpenJDK (currently 21). But we also now provide the ability to
4646
specify which version of Java you'd like via Docker tags:
4747

48-
JDK 1.8 tools-deps image: `clojure:temurin-8-tools-deps`
49-
JDK 11 variant of the tools-deps image: `clojure:temurin-11-tools-deps` or `clojure:temurin-11`
50-
JDK 17 with boot 2.8.3: `clojure:temurin-17-boot-2.8.3`
51-
JDK 20 with the latest version of lein: `clojure:temurin-20-lein`
52-
JDK 21 variant of the tools-deps image: `clojure:tools-deps` or `clojure:temurin-21` or `clojure:temurin-21-tools-deps`
48+
JDK 1.8 tools-deps image: `clojure:temurin-8-tools-deps`
49+
JDK 11 variant of the tools-deps image: `clojure:temurin-11-tools-deps` or `clojure:temurin-11`
50+
JDK 17 with boot 2.8.3: `clojure:temurin-17-boot-2.8.3`
51+
JDK 20 with the latest version of lein: `clojure:temurin-20-lein`
52+
JDK 21 variant of the tools-deps image: `clojure:tools-deps` or `clojure:temurin-21` or `clojure:temurin-21-tools-deps`
53+
JDK 22 variant of the tools-deps image: `clojure:temurin-22` or `clojure:temurin-22-tools-deps`
5354

5455
## Linux distro
5556

@@ -82,11 +83,12 @@ You can specify which distro & version you'd like by appending it to the end of
8283
your Docker tag as in the following examples (but note that not every
8384
combination is provided upstream and thus likewise for us):
8485

85-
Java 8 leiningen on Debian bullseye-slim: `clojure:temurin-8-lein-bullseye-slim`
86-
Java 11 leiningen on Debian bullseye: `clojure:temurin-11-lein-bullseye`
87-
Java 17 tools-deps on Ubuntu focal: `clojure:tools-deps` or `clojure:temurin-17` or `clojure:temurin-17-tools-deps` or `clojure:temurin-17-tools-deps-focal`
88-
Java 17 tools-deps on Debian bullseye-slim: `clojure:bullseye-slim` or `clojure:tools-deps-bullseye-slim` or `clojure:temurin-17-bullseye-slim` or `clojure:temurin-17-tools-deps-bullseye-slim`
89-
Java 21 tools-deps on Debian bookworm: `clojure:tools-deps` or `clojure:temurin-21-tools-deps` or `clojure:temurin-21-bookworm`
86+
Java 8 leiningen on Debian bullseye-slim: `clojure:temurin-8-lein-bullseye-slim`
87+
Java 11 leiningen on Debian bullseye: `clojure:temurin-11-lein-bullseye`
88+
Java 17 tools-deps on Ubuntu focal: `clojure:tools-deps` or `clojure:temurin-17` or `clojure:temurin-17-tools-deps` or `clojure:temurin-17-tools-deps-focal`
89+
Java 17 tools-deps on Debian bullseye-slim: `clojure:bullseye-slim` or `clojure:tools-deps-bullseye-slim` or `clojure:temurin-17-bullseye-slim` or `clojure:temurin-17-tools-deps-bullseye-slim`
90+
Java 21 tools-deps on Debian bookworm: `clojure:tools-deps` or `clojure:temurin-21-tools-deps` or `clojure:temurin-21-bookworm`
91+
Java 22 leiningen on Debian bookworm: `clojure:temurin-21-lein-bookworm`
9092

9193
### Alpine Linux
9294

@@ -96,8 +98,8 @@ As of 2022-9-29 these are available for the linux/amd64 architecture only.
9698

9799
Some example tags:
98100

99-
Java 17 leiningen on Alpine: `clojure:temurin-17-alpine` `clojure:temurin-17-lein-alpine`
100-
Java 20 tools-deps on Alpine: `clojure:temurin-20-tools-deps-alpine` or `clojure:temurin-20-alpine`
101+
Java 17 leiningen on Alpine: `clojure:temurin-17-alpine` `clojure:temurin-17-lein-alpine`
102+
Java 21 tools-deps on Alpine: `clojure:temurin-21-tools-deps-alpine` or `clojure:temurin-21-alpine`
101103

102104
## Examples
103105

@@ -144,4 +146,4 @@ linux/arm64).
144146
## Tests
145147

146148
The `docker-clojure` build tool has a test suite that can be run via the
147-
`bb run test` script.
149+
`bb run test` script.

src/docker_clojure/config.clj

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@
2828
(s/nilable (s/and ::non-blank-string #(re-matches #"[\d\.]+" %))))
2929
(s/def ::build-tools (s/map-of ::build-tool ::build-tool-version))
3030

31-
(s/def ::exclusions
32-
(s/keys :opt-un [::jdk-version ::distro ::build-tool ::build-tool-version]))
33-
3431
(s/def ::maintainers
3532
(s/coll-of ::non-blank-string :distinct true :into #{}))
3633

@@ -39,7 +36,7 @@
3936

4037
(def git-repo "https://github.com/Quantisan/docker-clojure.git")
4138

42-
(def jdk-versions #{8 11 17 21})
39+
(def jdk-versions #{8 11 17 21 22})
4340

4441
(def base-images
4542
"Map of JDK version to base image name(s) with :default as a fallback"
@@ -95,14 +92,13 @@
9592
; issue like this.
9693

9794
; no more focal builds for JDK 20+
98-
; TODO: Add ability to specify version >= 20 for these
99-
{:jdk-version 21
95+
{:jdk-version #(>= % 20)
10096
:distro :ubuntu/focal}
97+
; boot is breaking on Alpine
10198
{:build-tool "boot"
102-
:distro :alpine/alpine} ; boot is breaking on Alpine
99+
:distro :alpine/alpine}
103100
; we're no longer building boot variants for JDK 20+
104-
; TODO: Add ability to specify version >= 20 for these
105-
{:jdk-version 21
101+
{:jdk-version #(>= % 20)
106102
:build-tool "boot"}
107103
;; commented out example
108104
#_{:jdk-version 8

src/docker_clojure/core.clj

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,19 @@
1414
[docker-clojure.log :refer [log] :as logger]
1515
[clojure.edn :as edn]))
1616

17-
(defn contains-every-key-value?
18-
"Returns true if the map `haystack` contains every key-value pair in the map
19-
`needles`. `haystack` may contain additional keys that are not in `needles`.
20-
Returns false if any of the keys in `needles` are missing from `haystack` or
21-
have different values."
22-
[haystack needles]
17+
(defn exclude-variant?
18+
"Returns true if the map `variant` contains every key-value pair in the map
19+
`exclusion`. `variant` may contain additional keys that are not in
20+
`exclusion`. Some values of `exclusion` can also be a predicate of one
21+
argument which is then tested against the respective value from `variant`.
22+
Returns false if any of the keys in `exclusions` are missing from `variant` or
23+
have different values, or the predicate value returned false."
24+
[variant exclusion]
2325
(every? (fn [[k v]]
24-
(= v (get haystack k)))
25-
needles))
26+
(if (fn? v)
27+
(v (get variant k))
28+
(= v (get variant k))))
29+
exclusion))
2630

2731
(defn base-image-tag
2832
[base-image jdk-version distro]
@@ -37,7 +41,7 @@
3741
"Returns true if `variant` matches one of `exclusions` elements (meaning
3842
`(contains-every-key-value? variant exclusion)` returns true)."
3943
[exclusions variant]
40-
(some (partial contains-every-key-value? variant) exclusions))
44+
(some (partial exclude-variant? variant) exclusions))
4145

4246
(s/def ::variant
4347
(s/keys :req-un [::cfg/jdk-version ::cfg/base-image ::cfg/base-image-tag
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
FROM debian:bookworm
2+
3+
ENV JAVA_HOME=/opt/java/openjdk
4+
COPY --from=eclipse-temurin:22 $JAVA_HOME $JAVA_HOME
5+
ENV PATH="${JAVA_HOME}/bin:${PATH}"
6+
7+
ENV LEIN_VERSION=2.11.2
8+
ENV LEIN_INSTALL=/usr/local/bin/
9+
10+
WORKDIR /tmp
11+
12+
# Download the whole repo as an archive
13+
RUN set -eux; \
14+
apt-get update && \
15+
apt-get install -y make gnupg wget && \
16+
rm -rf /var/lib/apt/lists/* && \
17+
mkdir -p $LEIN_INSTALL && \
18+
wget -q https://codeberg.org/leiningen/leiningen/raw/tag/$LEIN_VERSION/bin/lein-pkg && \
19+
echo "Comparing lein-pkg checksum ..." && \
20+
sha256sum lein-pkg && \
21+
echo "28a1a62668c5f427b413a8677e376affaa995f023b1fcd06e2d4c98ac1df5f3e *lein-pkg" | sha256sum -c - && \
22+
mv lein-pkg $LEIN_INSTALL/lein && \
23+
chmod 0755 $LEIN_INSTALL/lein && \
24+
export GNUPGHOME="$(mktemp -d)" && \
25+
export FILENAME_EXT=jar && \
26+
gpg --batch --keyserver hkps://keyserver.ubuntu.com --recv-keys 9D13D9426A0814B3373CF5E3D8A8243577A7859F && \
27+
wget -q https://codeberg.org/leiningen/leiningen/releases/download/$LEIN_VERSION/leiningen-$LEIN_VERSION-standalone.$FILENAME_EXT && \
28+
wget -q https://codeberg.org/leiningen/leiningen/releases/download/$LEIN_VERSION/leiningen-$LEIN_VERSION-standalone.$FILENAME_EXT.asc && \
29+
echo "Verifying file PGP signature..." && \
30+
gpg --batch --verify leiningen-$LEIN_VERSION-standalone.$FILENAME_EXT.asc leiningen-$LEIN_VERSION-standalone.$FILENAME_EXT && \
31+
gpgconf --kill all && \
32+
rm -rf "$GNUPGHOME" leiningen-$LEIN_VERSION-standalone.$FILENAME_EXT.asc && \
33+
mkdir -p /usr/share/java && \
34+
mv leiningen-$LEIN_VERSION-standalone.$FILENAME_EXT /usr/share/java/leiningen-$LEIN_VERSION-standalone.jar && \
35+
apt-get purge -y --auto-remove gnupg wget
36+
37+
ENV PATH=$PATH:$LEIN_INSTALL
38+
ENV LEIN_ROOT 1
39+
40+
# Install clojure 1.11.1 so users don't have to download it every time
41+
RUN echo '(defproject dummy "" :dependencies [[org.clojure/clojure "1.11.1"]])' > project.clj \
42+
&& lein deps && rm project.clj
43+
44+
COPY entrypoint /usr/local/bin/entrypoint
45+
46+
ENTRYPOINT ["entrypoint"]
47+
CMD ["repl"]
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env bash
2+
3+
set -eou pipefail
4+
5+
entrypoint=lein
6+
7+
cmd=${1:-}
8+
9+
# check if the first arg starts with a hyphen
10+
if [ "$#" -eq 0 ] || [ "${1#-}" != "$1" ]; then
11+
exec "${entrypoint}" "$@"
12+
fi
13+
14+
if [[ -n "${cmd}" ]]; then
15+
# see if help for the subcommand is successful
16+
if "${entrypoint}" "${cmd}" --help >/dev/null 2>&1; then
17+
exec "${entrypoint}" "$@"
18+
fi
19+
fi
20+
21+
exec "$@"
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
FROM debian:bookworm
2+
3+
ENV JAVA_HOME=/opt/java/openjdk
4+
COPY --from=eclipse-temurin:22 $JAVA_HOME $JAVA_HOME
5+
ENV PATH="${JAVA_HOME}/bin:${PATH}"
6+
7+
ENV CLOJURE_VERSION=1.11.1.1435
8+
9+
WORKDIR /tmp
10+
11+
RUN \
12+
apt-get update && \
13+
apt-get install -y curl make git rlwrap wget && \
14+
rm -rf /var/lib/apt/lists/* && \
15+
wget https://download.clojure.org/install/linux-install-$CLOJURE_VERSION.sh && \
16+
sha256sum linux-install-$CLOJURE_VERSION.sh && \
17+
echo "7edee5b12197a2dbe6338e672b109b18164cde84bea1f049ceceed41fc4dd10a *linux-install-$CLOJURE_VERSION.sh" | sha256sum -c - && \
18+
chmod +x linux-install-$CLOJURE_VERSION.sh && \
19+
./linux-install-$CLOJURE_VERSION.sh && \
20+
rm linux-install-$CLOJURE_VERSION.sh && \
21+
clojure -e "(clojure-version)" && \
22+
apt-get purge -y --auto-remove curl wget
23+
24+
# Docker bug makes rlwrap crash w/o short sleep first
25+
# Bug: https://github.com/moby/moby/issues/28009
26+
# As of 2021-09-10 this bug still exists, despite that issue being closed
27+
COPY rlwrap.retry /usr/local/bin/rlwrap
28+
29+
COPY entrypoint /usr/local/bin/entrypoint
30+
31+
ENTRYPOINT ["entrypoint"]
32+
CMD ["-M", "--repl"]
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env bash
2+
3+
set -eou pipefail
4+
5+
entrypoint=clj
6+
7+
cmd=${1:-}
8+
9+
# check if the first arg starts with a hyphen
10+
if [ "$#" -eq 0 ] || [ "${1#-}" != "$1" ]; then
11+
exec "${entrypoint}" "$@"
12+
fi
13+
14+
if [[ -n "${cmd}" ]]; then
15+
# see if help for the subcommand is successful
16+
if "${entrypoint}" "${cmd}" --help >/dev/null 2>&1; then
17+
exec "${entrypoint}" "$@"
18+
fi
19+
fi
20+
21+
exec "$@"
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/sh
2+
3+
# This script works around a Docker bug that prevents rlwrap from starting
4+
# right when a container is first started. It is intended to replace
5+
# /usr/bin/rlwrap and also be named rlwrap but earlier in the PATH
6+
# (e.g. /usr/local/bin).
7+
8+
max_tries=100 # 100 tries is ~1 second
9+
try=0
10+
11+
while true; do
12+
# see if rlwrap can start at all
13+
output=$(/usr/bin/rlwrap true 2>&1 >/dev/null)
14+
exit_code=$?
15+
if [ $exit_code -gt 0 ]; then
16+
# it didn't start
17+
try=$((try+1))
18+
if [ $try -gt $max_tries ]; then
19+
# we're at max attempts so output the error and exit w/ the same code
20+
echo "$output" >&2
21+
exit $exit_code
22+
else
23+
# wait a bit and try again
24+
sleep 0.01
25+
fi
26+
else
27+
# rlwrap can start so let's run it for real
28+
exec /usr/bin/rlwrap "$@"
29+
fi
30+
done
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
FROM debian:bookworm-slim
2+
3+
ENV JAVA_HOME=/opt/java/openjdk
4+
COPY --from=eclipse-temurin:22 $JAVA_HOME $JAVA_HOME
5+
ENV PATH="${JAVA_HOME}/bin:${PATH}"
6+
7+
ENV LEIN_VERSION=2.11.2
8+
ENV LEIN_INSTALL=/usr/local/bin/
9+
10+
WORKDIR /tmp
11+
12+
# Download the whole repo as an archive
13+
RUN set -eux; \
14+
apt-get update && \
15+
apt-get install -y gnupg wget && \
16+
rm -rf /var/lib/apt/lists/* && \
17+
mkdir -p $LEIN_INSTALL && \
18+
wget -q https://codeberg.org/leiningen/leiningen/raw/tag/$LEIN_VERSION/bin/lein-pkg && \
19+
echo "Comparing lein-pkg checksum ..." && \
20+
sha256sum lein-pkg && \
21+
echo "28a1a62668c5f427b413a8677e376affaa995f023b1fcd06e2d4c98ac1df5f3e *lein-pkg" | sha256sum -c - && \
22+
mv lein-pkg $LEIN_INSTALL/lein && \
23+
chmod 0755 $LEIN_INSTALL/lein && \
24+
export GNUPGHOME="$(mktemp -d)" && \
25+
export FILENAME_EXT=jar && \
26+
gpg --batch --keyserver hkps://keyserver.ubuntu.com --recv-keys 9D13D9426A0814B3373CF5E3D8A8243577A7859F && \
27+
wget -q https://codeberg.org/leiningen/leiningen/releases/download/$LEIN_VERSION/leiningen-$LEIN_VERSION-standalone.$FILENAME_EXT && \
28+
wget -q https://codeberg.org/leiningen/leiningen/releases/download/$LEIN_VERSION/leiningen-$LEIN_VERSION-standalone.$FILENAME_EXT.asc && \
29+
echo "Verifying file PGP signature..." && \
30+
gpg --batch --verify leiningen-$LEIN_VERSION-standalone.$FILENAME_EXT.asc leiningen-$LEIN_VERSION-standalone.$FILENAME_EXT && \
31+
gpgconf --kill all && \
32+
rm -rf "$GNUPGHOME" leiningen-$LEIN_VERSION-standalone.$FILENAME_EXT.asc && \
33+
mkdir -p /usr/share/java && \
34+
mv leiningen-$LEIN_VERSION-standalone.$FILENAME_EXT /usr/share/java/leiningen-$LEIN_VERSION-standalone.jar && \
35+
apt-get purge -y --auto-remove gnupg wget
36+
37+
ENV PATH=$PATH:$LEIN_INSTALL
38+
ENV LEIN_ROOT 1
39+
40+
# Install clojure 1.11.1 so users don't have to download it every time
41+
RUN echo '(defproject dummy "" :dependencies [[org.clojure/clojure "1.11.1"]])' > project.clj \
42+
&& lein deps && rm project.clj
43+
44+
COPY entrypoint /usr/local/bin/entrypoint
45+
46+
ENTRYPOINT ["entrypoint"]
47+
CMD ["repl"]
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env bash
2+
3+
set -eou pipefail
4+
5+
entrypoint=lein
6+
7+
cmd=${1:-}
8+
9+
# check if the first arg starts with a hyphen
10+
if [ "$#" -eq 0 ] || [ "${1#-}" != "$1" ]; then
11+
exec "${entrypoint}" "$@"
12+
fi
13+
14+
if [[ -n "${cmd}" ]]; then
15+
# see if help for the subcommand is successful
16+
if "${entrypoint}" "${cmd}" --help >/dev/null 2>&1; then
17+
exec "${entrypoint}" "$@"
18+
fi
19+
fi
20+
21+
exec "$@"

0 commit comments

Comments
 (0)