Skip to content
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
54 changes: 30 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ This image runs on OpenJDK 8, 11, and more recent releases and includes [Leining

## Leiningen vs. boot vs. tools-deps

The version tags on these images look like `(openjdk-major-version-)lein-N.N.N(-distro)`,
`(openjdk-major-version-)boot-N.N.N(-distro)`, and `(openjdk-major-version-)tools-deps(-distro)`.
The version tags on these images look like `(temurin-major-version-)lein-N.N.N(-distro)`,
`(temurin-major-version-)boot-N.N.N(-distro)`, and `(temurin-major-version-)tools-deps(-distro)`.
These refer to which version of leiningen, boot, or tools-deps is packaged in the image (because they can then install
and use any version of Clojure at runtime). The `lein` (or `lein-slim-bullseye`, `openjdk-14-lein`, etc.)
and use any version of Clojure at runtime). The `lein` (or `lein-slim-bullseye`, `temurin-17-lein`, etc.)
images will always have a recent version of leiningen installed. If you want boot, specify either `clojure:boot`,
`clojure:boot-slim-bullseye`, or `clojure:boot-N.N.N`, `clojure:boot-N.N.N-slim-bullseye`,
`clojure:openjdk-14-boot-N.N.N-slim-bullseye`, etc. (where `N.N.N` is the version of boot you want installed). If
`clojure:temurin-17-boot-N.N.N-slim-bullseye`, etc. (where `N.N.N` is the version of boot you want installed). If
you want to use tools-deps, specify either `clojure:tools-deps`, `clojure:tools-deps-slim-bullseye` or other similar
variants.

Expand All @@ -25,48 +25,54 @@ tools-deps installed.

Previously this tag only had leiningen installed. Installing the others is helpful for quick start examples, newcomers,
etc. as leiningen is by no means the de facto standard build tool these days. The downside is that the image is larger.
But for the `latest` tag it's a good trade off because for anything real we have always recommended using more specific
But for the `latest` tag it's a good trade-off because for anything real we have always recommended using more specific
tags. No other tags are affected by this change.

## JDK versions

Java has recently introduced a new release cadence of every 6 months and dropped the leading `1` major version number.
As of 2019-9-25, our images will default to the latest LTS release of OpenJDK (currently 11). But we also now provide
Java follows a release cadence of every 6 months with an LTS (long-term support) release every 3 years.
As of 2019-9-25, our images will default to the latest LTS release of OpenJDK (currently 17). But we also now provide
the ability to specify which version of Java you'd like via Docker tags:

JDK 1.8 tools-deps image: `clojure:openjdk-8-tools-deps`
JDK 11 variant of that image: `clojure:openjdk-11-tools-deps` or `clojure:tool-deps`
JDK 14 with the latest release of leiningen: `clojure:openjdk-14`
JDK 15 with boot 2.8.3: `clojure:openjdk-15-boot-2.8.3`
JDK 17 with the latest release of leiningen: `clojure:temurin-17`
JDK 18 with boot 2.8.3: `clojure:temurin-18-boot-2.8.3`

## Linux distro

The upstream OpenJDK images are built on a few different variants of Debian Linux, so we have exposed those in our
Docker tags as well. The default is now Debian slim-bullseye. But you can also specify which distro you'd like by
appending it to the end of your Docker tag as in the following examples (but note that not every combination is
provided upstream and thus likewise for us):
The upstream openjdk (java versions 11 and below) and eclipse-temurin
(java versions 17+) images are built on a few different variants of Debian
Linux or Ubuntu (respectively), so we have exposed those in our Docker tags as
well. The defaults are now Debian slim-bullseye and Ubuntu focal.
But you can also specify which distro you'd like by appending it to the end of
your Docker tag as in the following examples (but note that not every
combination is provided upstream and thus likewise for us):

JDK 1.8 leiningen on Debian slim-bullseye: `clojure:openjdk-8` or `clojure:openjdk-8-lein` or `clojure:openjdk-8-lein-stretch`
JDK 1.8 leiningen on Debian buster: `clojure:openjdk-8-buster` or `clojure:openjdk-8-lein-buster`
JDK 11 tools-deps on Debian slim-bullseye: `clojure:tools-deps` or `clojure:openjdk-11-tools-deps` or `clojure:openjdk-11-tools-deps-slim-bullseye`
Java 8 leiningen on Debian slim-bullseye: `clojure:openjdk-8` or `clojure:openjdk-8-lein` or `clojure:openjdk-8-lein-bullseye`
Java 11 leiningen on Debian buster: `clojure:openjdk-11-bullseye` or `clojure:openjdk-11-lein-bullseye`
Java 17 tools-deps on Ubuntu focal: `clojure:tools-deps` or `clojure:temurin-17-tools-deps` or `clojure:temurin-17-tools-deps-focal`

### Alpine Linux

Sometimes there are upstream openjdk images for early access JDK releases based
on Alpine Linux, but they have often later been deprecated once that version is
released.
Sometimes there are upstream openjdk or eclipse-temurin images based on Alpine
Linux.

As of 2021-09-08, there are alpine variants only for OpenJDK 18 early access.
As of 2022-4-29 these are available for linux/amd64 only.

Some example tags:

JDK 18 leiningen on Alpine: `clojure:openjdk-18-alpine` `clojure:openjdk-18-lein-alpine`
JDK 18 tools-deps on Alpine: `clojure:openjdk-18-tools-deps-alpine`
Java 17 leiningen on Alpine: `clojure:temurin-17-alpine` `clojure:temurin-17-lein-alpine`
Java 18 tools-deps on Alpine: `clojure:temurin-18-tools-deps-alpine`

### `clojure:slim-buster` / `clojure:slim-bullseye`

These images are based on the Debian buster distribution but have fewer packages installed and are thus much smaller
than the `stretch` or `buster` images. Their use is recommended.
These images are based on the Debian buster distribution but have fewer
packages installed and are thus a bit smaller than the `buster` or `bullseye`
images. Their use is recommended.

Note that as of 2022-4-29 there are no `slim-focal` images published by the
eclipse-temurin maintainers, so the slim option there is the `alpine` variant.

## Examples

Expand Down
4 changes: 0 additions & 4 deletions src/docker_clojure/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,6 @@
#{{:jdk-version 8
:distro :alpine/alpine}
{:jdk-version 11
:distro :alpine/alpine}
{:jdk-version 17
:distro :alpine/alpine}
{:jdk-version 18
:distro :alpine/alpine}})

(def maintainers
Expand Down
30 changes: 30 additions & 0 deletions target/eclipse-temurin-17-jdk-alpine/boot/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
FROM eclipse-temurin:17-jdk-alpine

ENV BOOT_VERSION=2.8.3
ENV BOOT_INSTALL=/usr/local/bin/

WORKDIR /tmp

# NOTE: BOOT_VERSION tells the boot.sh script which version of boot to install
# on its first run. We always download the latest version of boot.sh because
# it is just the installer script.
RUN \
apk add --no-cache bash openssl && \
mkdir -p $BOOT_INSTALL && \
wget -q https://github.com/boot-clj/boot-bin/releases/download/latest/boot.sh && \
echo "Comparing installer checksum..." && \
sha256sum boot.sh && \
echo "0ccd697f2027e7e1cd3be3d62721057cbc841585740d0aaa9fbb485d7b1f17c3 *boot.sh" | sha256sum -c - && \
mv boot.sh $BOOT_INSTALL/boot && \
chmod 0755 $BOOT_INSTALL/boot && \
apk del openssl

ENV PATH=$PATH:$BOOT_INSTALL
ENV BOOT_AS_ROOT=yes

RUN boot

COPY entrypoint /usr/local/bin/entrypoint

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

set -eou pipefail

entrypoint=boot

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 "$@"
46 changes: 46 additions & 0 deletions target/eclipse-temurin-17-jdk-alpine/lein/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
FROM eclipse-temurin:17-jdk-alpine

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

WORKDIR /tmp

# Download the whole repo as an archive
RUN set -eux; \
apk add --no-cache ca-certificates bash tar openssl gnupg && \
mkdir -p $LEIN_INSTALL && \
wget -q https://raw.githubusercontent.com/technomancy/leiningen/$LEIN_VERSION/bin/lein-pkg && \
echo "Comparing lein-pkg checksum ..." && \
sha256sum lein-pkg && \
echo "9952cba539cc6454c3b7385ebce57577087bf2b9001c3ab5c55d668d0aeff6e9 *lein-pkg" | sha256sum -c - && \
mv lein-pkg $LEIN_INSTALL/lein && \
chmod 0755 $LEIN_INSTALL/lein && \
export GNUPGHOME="$(mktemp -d)" && \
export FILENAME_EXT=jar && \
if printf '%s\n%s\n' "2.9.7" "$LEIN_VERSION" | sort -cV; then \
gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys 6A2D483DB59437EBB97D09B1040193357D0606ED; \
else \
gpg --batch --keyserver hkps://keyserver.ubuntu.com --recv-keys 20242BACBBE95ADA22D0AFD7808A33D379C806C3; \
FILENAME_EXT=zip; \
fi && \
wget -q https://github.com/technomancy/leiningen/releases/download/$LEIN_VERSION/leiningen-$LEIN_VERSION-standalone.$FILENAME_EXT && \
wget -q https://github.com/technomancy/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 && \
mv leiningen-$LEIN_VERSION-standalone.$FILENAME_EXT /usr/share/java/leiningen-$LEIN_VERSION-standalone.jar && \
apk del ca-certificates tar openssl gnupg

ENV PATH=$PATH:$LEIN_INSTALL
ENV LEIN_ROOT 1

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

COPY entrypoint /usr/local/bin/entrypoint

ENTRYPOINT ["entrypoint"]
CMD ["repl"]
21 changes: 21 additions & 0 deletions target/eclipse-temurin-17-jdk-alpine/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 "$@"
26 changes: 26 additions & 0 deletions target/eclipse-temurin-17-jdk-alpine/tools-deps/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
FROM eclipse-temurin:17-jdk-alpine

ENV CLOJURE_VERSION=1.11.1.1113

WORKDIR /tmp

RUN \
apk add --no-cache curl bash make git && \
wget https://download.clojure.org/install/linux-install-$CLOJURE_VERSION.sh && \
sha256sum linux-install-$CLOJURE_VERSION.sh && \
echo "7677bb1179ebb15ebf954a87bd1078f1c547673d946dadafd23ece8cd61f5a9f *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)" && \
apk del 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/eclipse-temurin-17-jdk-alpine/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/eclipse-temurin-17-jdk-alpine/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
30 changes: 30 additions & 0 deletions target/eclipse-temurin-18-jdk-alpine/boot/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
FROM eclipse-temurin:18-jdk-alpine

ENV BOOT_VERSION=2.8.3
ENV BOOT_INSTALL=/usr/local/bin/

WORKDIR /tmp

# NOTE: BOOT_VERSION tells the boot.sh script which version of boot to install
# on its first run. We always download the latest version of boot.sh because
# it is just the installer script.
RUN \
apk add --no-cache bash openssl && \
mkdir -p $BOOT_INSTALL && \
wget -q https://github.com/boot-clj/boot-bin/releases/download/latest/boot.sh && \
echo "Comparing installer checksum..." && \
sha256sum boot.sh && \
echo "0ccd697f2027e7e1cd3be3d62721057cbc841585740d0aaa9fbb485d7b1f17c3 *boot.sh" | sha256sum -c - && \
mv boot.sh $BOOT_INSTALL/boot && \
chmod 0755 $BOOT_INSTALL/boot && \
apk del openssl

ENV PATH=$PATH:$BOOT_INSTALL
ENV BOOT_AS_ROOT=yes

RUN boot

COPY entrypoint /usr/local/bin/entrypoint

ENTRYPOINT ["entrypoint"]
CMD ["repl"]
21 changes: 21 additions & 0 deletions target/eclipse-temurin-18-jdk-alpine/boot/entrypoint
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env bash

set -eou pipefail

entrypoint=boot

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