Skip to content

Commit

Permalink
fixup test
Browse files Browse the repository at this point in the history
  • Loading branch information
gdams committed Nov 2, 2023
1 parent 5d2360f commit f01c6e5
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 53 deletions.
10 changes: 0 additions & 10 deletions .test/tests/dotted-environment-variables/image-name.sh

This file was deleted.

44 changes: 1 addition & 43 deletions .test/tests/dotted-environment-variables/run.sh
Original file line number Diff line number Diff line change
@@ -1,49 +1,7 @@
#!/usr/bin/env bash

## Copied from https://github.com/docker-library/official-images/blob/master/test/tests/run-java-in-container.sh

set -Eeuo pipefail

testDir="$(readlink -f "$(dirname "$BASH_SOURCE")")"
runDir="$(dirname "$(readlink -f "$BASH_SOURCE")")"

image="$1"

# do a little extra work to try and find a suitable JDK image (when "xyzjava:1.2.3-jre" first builds, "xyzjava:1.2.3-jdk" isn't published yet :D)
tryJdks=(
# ideally, we'd just swap the current JRE image to JDK, but that might not exist yet (see above)
"${image/jre/jdk}"
)
jdk=
for potentialJdk in "${tryJdks[@]}"; do
if docker run --rm --pull=missing "$potentialJdk" javac -help &> /dev/null; then
jdk="$potentialJdk"
break
fi
done
if [ -z "$jdk" ]; then
echo >&2 "error: failed to find a suitable JDK image for '$image'!"
exit 1
fi
if [ "$jdk" != "${tryJdks[0]}" ]; then
echo >&2 "warning: using '$jdk' instead of '${tryJdks[0]}' (results may vary!)"
fi

# if possible, use "--release" in case $jdk and $image have mismatching Java versions
javac='javac'
if docker run --rm "$jdk" javac --help 2>&1 | grep -q -- '--release'; then
javac='javac --release 8'
fi

newImage="$("$runDir/image-name.sh" librarytest/java-hello-world "$image")"
"$runDir/docker-build.sh" "$testDir" "$newImage" <<EOD
FROM $jdk AS jdk
WORKDIR /container
COPY dir/container.java ./
RUN $javac ./container.java
FROM $image
COPY --from=jdk /container /container
WORKDIR /container
EOD

docker run --rm -e "variable.with.a.dot=a.dotted.value" "$newImage" java -cp . container
docker run --rm -e "variable.with.a.dot=a.dotted.value" "$image" java -cp . container

0 comments on commit f01c6e5

Please sign in to comment.