#!/usr/bin/env bash # Run Maven inside the DangerousThings smartcard-ci Docker image. # # The image (vivokey/smartcard-ci) ships a pre-built jcardsim-3.0.5-SNAPSHOT, # Oracle JavaCard SDKs, Java 8, and Maven. On first run we seed a named # Docker volume with the image's baseline .m2 so subsequent runs keep # downloaded deps (JUnit etc.) warm between invocations. # # Usage: ./scripts/dt-mvn.sh e.g.: ./scripts/dt-mvn.sh -q test set -euo pipefail IMAGE="vivokey/smartcard-ci:latest" VOLUME="aliro-smartcard-m2" project_root="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." &> /dev/null && pwd)" if ! docker volume inspect "$VOLUME" >/dev/null 2>&1; then echo "Seeding $VOLUME with baseline .m2 from $IMAGE (one-time)" >&2 docker volume create "$VOLUME" >/dev/null docker run --rm -v "$VOLUME:/dst" --entrypoint sh "$IMAGE" \ -c 'cp -a /root/.m2/. /dst/ && chmod -R a+rwX /dst' fi exec docker run --rm -t \ -v "$project_root:/work" -w /work \ -v "$VOLUME:/root/.m2" \ -e JC_CLASSIC_HOME=/app/sdks/jc305u3_kit \ "$IMAGE" "mvn $*"