Skip to content

Instantly share code, notes, and snippets.

@kinow
Last active August 8, 2024 20:06
Show Gist options
  • Save kinow/c227a7f0ea1c509a36f57beb02e9d8e3 to your computer and use it in GitHub Desktop.
Save kinow/c227a7f0ea1c509a36f57beb02e9d8e3 to your computer and use it in GitHub Desktop.
jena-build-docker

Reproduced the failure reported on the mailing-list with:

docker run \
  --sysctl net.ipv6.conf.all.disable_ipv6=1 \
  --rm -ti --name jena-build \
  -v "/home/kinow/Development/java/workspace/jena":/usr/src/mymaven \
  -w /usr/src/mymaven \
  maven:3.9.8-eclipse-temurin-21-jammy \
  mvn --batch-mode --errors --fail-at-end --show-version clean test install --projects jena-fuseki2/jena-fuseki-ui

Without disabling ipv6 it gets stuck as (I think) wait-on fails to wait for the URL to be available (wait-on is used to wait for the fake-fuseki and the vite dev server to be available for the Cypress tests).

The tests fail complaining that the Cypress binary cannot be found, as reported on the mailing list.

Using the image created with the attached Dockerfile, and built with a name and tag like jena-build:latest (this example, give it any name), one can test Jena Fuseki UI with:

docker run \
  --sysctl net.ipv6.conf.all.disable_ipv6=1 \
  --rm -ti --name jena-build \
  -v "/home/kinow/Development/java/workspace/jena":/usr/src/mymaven \
  -w /usr/src/mymaven \
  jena/build:latest \
  mvn --batch-mode --errors --fail-at-end --show-version clean test install --projects jena-fuseki2/jena-fuseki-ui

This works as the jena/build:latest image will include Cypress from cypress/included, and also mvn and java from the Maven official image. And the tests won't hang or get stuck as wait-on should work without ipv6. Just make sure to use the same version of the cypress/included container for the version of Cypress in package.json.

You can remove the --projects option to build the whole project, but this test was only for Fuseki UI with Cypress.

# A multi-stage image with Cypress and Java+Maven for Jena... ALv2...
# To build it:
# `docker build -t jena/build:latest .`
#
# To run it:
# `docker run --entrypoint "" --rm -ti jena/build:latest /bin/bash`
FROM 'maven:3.9.8-eclipse-temurin-21-jammy' AS maven
# The Maven stage. Nothing to see here, we simply copy artefacts
# from this stage onto the next one.
# Docs: https://hub.docker.com/_/maven
FROM 'cypress/included:13.13.1'
# The image with Cypress and everything else included. Compatible
# with temurin jammy, so we can just copy Maven and Java, and set
# the $PATH.
# Docs: https://hub.docker.com/r/cypress/included
#
# NOTE: The Cypress image must match our Cypress version in package.json.
# This is due to how Cypress loads the binary from the cache. It'll
# expect a binary at `/root/.cache/Cypress/$version/Cypress/`. With
# the `$version` coming from the version from the package.json file.
COPY --from=maven /usr/share/maven/ /usr/share/maven/
COPY --from=maven /opt/java/ /opt/java
ENV PATH="/usr/share/maven/bin:/opt/java/openjdk/bin:$PATH"
ENTRYPOINT [""]
CMD ["mvn"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment