jq version 1.7 is out and I’d like to provide it in the test runner so students can benefit from the features and fixed. However all the major distributions package version 1.6. I’ve discovered that alpine:edge
offers jq 1.7. Switching to alpine reduces the size of the test runner to about 10MB which is nice, but using the edge
release makes me a little nervous.
FROM alpine:edge
# bash - v5.2.15-r6
# bats - v1.10.0-r0
# jq - v1.7-r2
RUN apk add --no-cache bash bats jq
WORKDIR /opt/test-runner
COPY . .
ENV BATS_RUN_SKIPPED=true
ENTRYPOINT ["/opt/test-runner/bin/run.sh"]
My alternative is to build jq from source. I hacked up this Dockerfile:
FROM debian:12-slim AS builder
ENV LC_ALL=C.UTF-8 \
LANG=C.UTF-8
RUN apt-get update \
&& apt-get install -y build-essential \
autoconf \
libtool \
git \
&& : ==== install jq v1.7 ==== \
&& cd /tmp \
&& git clone https://github.com/jqlang/jq \
&& cd jq \
&& git checkout jq-1.7 \
&& git submodule update --init \
&& cd modules/oniguruma/ \
&& git checkout v6.9.9 \
&& cd ../.. \
&& autoreconf -i \
&& ./configure --disable-docs \
--disable-valgrind \
--with-oniguruma=builtin \
--enable-static \
--enable-all-static \
--prefix=/usr/local \
&& make -j$(nproc) \
&& make check \
&& make install-strip \
&& : ==== install bats v1.7 ==== \
&& cd /tmp \
&& git clone https://github.com/bats-core/bats-core \
&& cd bats-core \
&& git checkout v1.7.0 \
&& bash ./install.sh /usr/local
#############################################################
FROM debian:12-slim
RUN mkdir -p /usr/local/lib/bats-core /usr/local/libexec/bats-core
COPY --from=builder /usr/local/bin/jq /usr/local/bin/bats /usr/local/bin/
COPY --from=builder /usr/local/lib/bats-core/ /usr/local/lib/bats-core/
COPY --from=builder /usr/local/libexec/bats-core/ /usr/local/libexec/bats-core/
WORKDIR /opt/test-runner
COPY . .
ENV BATS_RUN_SKIPPED=true
ENTRYPOINT ["/opt/test-runner/bin/run.sh"]
Obviously more complicated. I don’t know if the builder image gets correctly thrown away: the resulting image is about 77MB.
Thoughts? @ErikSchierboom ?