|
| 1 | +#!/usr/bin/env sh |
| 2 | + |
| 3 | +# Synopsis: |
| 4 | +# Build a Docker image containing a CraC checkpoint to restart from. |
| 5 | +# An initial image is built. A container is created from that image |
| 6 | +# and tests are run to warm up the JVM. Then a checkpoint is created. |
| 7 | +# The final image is created by committing the containiner |
| 8 | +# containing the checkpoint. |
| 9 | + |
| 10 | +docker build -t exercism/java-test-runner-crac-checkpoint . |
| 11 | + |
| 12 | +# Copy all tests into one merged project, so we can warm up the JVM |
| 13 | +# TODO(FAP): this is missing some tests as most tests use the same filenames |
| 14 | +mkdir -p tests/merged |
| 15 | +for dir in tests/*; do |
| 16 | + if [ -d "$dir" ] && [ "$dir" != "tests/merged/" ]; then |
| 17 | + rsync -a "$dir"/ tests/merged/ |
| 18 | + fi |
| 19 | +done |
| 20 | + |
| 21 | +slug="merged" |
| 22 | +solution_dir=$(realpath "tests/merged/") |
| 23 | +output_dir=$(realpath "tests/merged/") |
| 24 | + |
| 25 | +docker run --cap-add CHECKPOINT_RESTORE \ |
| 26 | + --cap-add SYS_PTRACE \ |
| 27 | + --name java-test-runner-crac \ |
| 28 | + --network none \ |
| 29 | + --mount type=bind,src="${solution_dir}",dst=/solution \ |
| 30 | + --mount type=bind,src="${output_dir}",dst=/output \ |
| 31 | + --mount type=tmpfs,dst=/tmp \ |
| 32 | + --tmpfs /openjfx:exec,rw \ |
| 33 | + exercism/java-test-runner-crac-checkpoint "${slug}" /solution /output |
| 34 | + |
| 35 | +docker commit --change='ENTRYPOINT ["sh", "/opt/test-runner/bin/run-restore-from-checkpoint.sh"]' java-test-runner-crac exercism/java-test-runner-crac-restore |
| 36 | + |
| 37 | +docker rm -f java-test-runner-crac |
| 38 | +rm -rf tests/merged/ |
0 commit comments