To use a bleeding edge alpine image for a test runner or not to use

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 ?

Alpine Linux 3.19.0 will be released relatively soon (in November), and will include jq 1.7. If we wanted to update jq before then, I think we’re unlikely to encounter problems if we use alpine:edge in the meantime. Especially given that CI for the jq-test-runner repo seems to use run-tests-in-docker.sh to test the production interface.

But as an alternative, would it be possible to use Alpine stable, plus jq 1.7? This would involve something like:

apk add --no-cache --repository https://dl-cdn.alpinelinux.org/alpine/edge/main jq

Looks good to me. But I recommend GitHub - wagoodman/dive: A tool for exploring each layer in a docker image if you want to investigate docker image sizes.

1 Like

Ooh, great tip!

I realized the next tricky bit is CI for jq track. Since it runs on ubuntu-latest I’d have to jump through those tricky hoops to get jq 1.7 built on it. I suppose I could be content with the example solutions being tested on jq 1.6 as long as students get to use v1.7

That would be fine I think. But you could “just” download a jq 1.7 binary in CI?

Certainly do-able, but what architecture to choose?

Documentation for “runs-on” doesn’t mention it.

I think it’s x86-64.

The test runner PR: https://github.com/exercism/jq-test-runner/pull/18

The jq track PR: https://github.com/exercism/jq/pull/191

@ErikSchierboom I’ll need your approval for the first one.

@ee7-1282 FYI

Approval granted!

Yes, currently every hosted GitHub Actions runner is x86_64 except macos-latest-xlarge and macos-13-xlarge (which are arm64, and in beta). But every Exercism Dockerfile is x86_64 anyway.