Skip to content

Commit

Permalink
updated Java S2I build
Browse files Browse the repository at this point in the history
  • Loading branch information
amoldavsky committed Jul 21, 2020
1 parent 1058854 commit 3b829dc
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 2 deletions.
3 changes: 2 additions & 1 deletion incubating/wrappers/s2i/java/Dockerfile.build
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FROM seldonio/core-builder:0.3
ARG IMAGE_SOURCE=seldonio/core-builder:0.3
FROM $IMAGE_SOURCE

LABEL io.openshift.s2i.scripts-url="image:///s2i/bin"

Expand Down
3 changes: 2 additions & 1 deletion incubating/wrappers/s2i/java/Dockerfile.runtime
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FROM openjdk:8u131-jre-alpine
ARG IMAGE_SOURCE=openjdk:8u131-jre-alpine
FROM $IMAGE_SOURCE

RUN apk update && apk add bash

Expand Down
76 changes: 76 additions & 0 deletions incubating/wrappers/s2i/java/bin/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#!/usr/bin/env bash
set -x

#
# Print the usage and exit.
#
function usage () {
echo "Usage: $0 [OPTIONS] VERSION"
echo "\r\n"
echo "Options: "
echo " --build-source-image (OPTIONAL) override the build image source image"
echo " --build-runtime-image (OPTIONAL) override the runtime image source image"
exit 1
}

# Parse the arguments.
# loop until last - 1, we assume the last arg is the model name
while [[ $# -ge 2 ]]
do
key="$1"
case ${key} in
--build-source-image)
BUILD_SOURCE_IMAGE="$2"
shift # past key
shift # past value
;;
--runtime-source-image)
RUNTIME_SOURCE_IMAGE="$2"
shift # past key
shift # past value
;;
*)
usage
;;
esac
done

# assign last parameter to model
VERSION=${@:${#@}}
IMAGE_BUILD_BUILD_ARGS=""
IMAGE_RUNTIME_BUILD_ARGS=""

# Validate the arguments.
if [[ -z "$VERSION" ]]; then
echo "Missing argument: VERSION."
usage
fi

# Prepare Docker build args ( if supplied )
if ! [[ -z "$BUILD_SOURCE_IMAGE" ]]; then
IMAGE_BUILD_BUILD_ARGS=$(echo "$IMAGE_BUILD_BUILD_ARGS --build-arg IMAGE_SOURCE=$BUILD_SOURCE_IMAGE" | awk '{$1=$1};1')
fi
if ! [[ -z "$RUNTIME_SOURCE_IMAGE" ]]; then
IMAGE_RUNTIME_BUILD_ARGS=$(echo "$IMAGE_RUNTIME_BUILD_ARGS --build-arg IMAGE_SOURCE=$RUNTIME_SOURCE_IMAGE" | awk '{$1=$1};1')
fi

IMAGE_NAME_BUILD=docker.io/seldonio/seldon-core-s2i-java-build:${VERSION}
IMAGE_NAME_RUNTIME=docker.io/seldonio/seldon-core-s2i-java-runtime:${VERSION}

echo "S2I build image: building..."
docker build \
-f Dockerfile.build \
-t ${IMAGE_NAME_BUILD} \
${IMAGE_BUILD_BUILD_ARGS} \
.
echo "S2I build image: check Java version..."
docker run --entrypoint "/bin/bash" ${IMAGE_NAME_BUILD} "-c" "java --version"

echo "S2I runtime image: building..."
docker build \
-f Dockerfile.runtime \
-t ${IMAGE_NAME_RUNTIME} \
${IMAGE_RUNTIME_BUILD_ARGS} \
.
echo "S2I runtime image: check Java version..."
docker run --entrypoint "/bin/bash" ${IMAGE_NAME_RUNTIME} "-c" "java --version"

0 comments on commit 3b829dc

Please sign in to comment.