Add script that uses pack to create a container from a downloaded application jar. (#383)
Provides a way to resolve. https://github.com/spring-cloud/spring-cloud-dataflow/issues/5040
This commit is contained in:
committed by
GitHub
parent
c92f7d44ab
commit
7188d3737c
@@ -25,6 +25,19 @@ Usage: `create-containers.sh [version] [broker] [jre-version] [filter]`
|
||||
* `jre-version` should be one of 11, 17
|
||||
* `filter` is a name of an application or a partial name that will be matched.
|
||||
|
||||
If the file is not present required to create the
|
||||
If the file is not present required to create the container the script will skip the one.
|
||||
|
||||
## `pack-containers.sh`
|
||||
Creates all containers and pushes to local docker registry.
|
||||
|
||||
This script requires [pack](https://buildpacks.io/docs/tools/pack/)
|
||||
|
||||
Usage: `pack-containers.sh [version] [broker] [jre-version] [filter]`
|
||||
* `version` is the skipper version like `3.2.1` or default is `3.2.2-SNAPSHOT`
|
||||
* `broker` is one of rabbitmq, rabbit or kafka
|
||||
* `jre-version` should be one of 11, 17
|
||||
* `filter` is a name of an application or a partial name that will be matched.
|
||||
|
||||
If the file is not present required to create the container the script will skip the one.
|
||||
|
||||
*If any parameter is provided all those to the left of it should be considered required.*
|
||||
135
local/pack-containers.sh
Executable file
135
local/pack-containers.sh
Executable file
@@ -0,0 +1,135 @@
|
||||
#!/usr/bin/env bash
|
||||
SCDIR=$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")
|
||||
SCDIR=$(realpath $SCDIR)
|
||||
ROOT_DIR=$(realpath $SCDIR/..)
|
||||
|
||||
# set to specific version
|
||||
if [ "$1" != "" ]; then
|
||||
TAG=$1
|
||||
else
|
||||
TAG=2.10.0-SNAPSHOT
|
||||
fi
|
||||
case $2 in
|
||||
"rabbitmq" | "rabbit")
|
||||
BROKER=rabbit
|
||||
;;
|
||||
"kafka")
|
||||
BROKER=kafka
|
||||
;;
|
||||
"")
|
||||
echo "Broker default to rabbit"
|
||||
BROKER=rabbit
|
||||
;;
|
||||
*)
|
||||
echo "Invalid broker name $1"
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ "$3" != "" ]; then
|
||||
v=$3
|
||||
else
|
||||
v=11
|
||||
fi
|
||||
|
||||
FILTER=$4
|
||||
PROCESSOR=$(uname -p)
|
||||
if [ "$ARCH" == "" ]; then
|
||||
case $PROCESSOR in
|
||||
"x86_64")
|
||||
ARCH=amd64
|
||||
;;
|
||||
*)
|
||||
if [[ "$PROCESSOR" == *"arm"* ]]; then
|
||||
ARCH=arm64v8
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
IMAGE="$ARCH/eclipse-temurin:$v-jdk-jammy"
|
||||
CRED=
|
||||
if [ "$DOCKER_USERNAME" != "" ]; then
|
||||
CRED="--from-username=$DOCKER_USERNAME --from-password=$DOCKER_PASSWORD"
|
||||
fi
|
||||
# set with extra option for buildpacks. BP_OPTIONS=
|
||||
pushd $ROOT_DIR/applications/processor >/dev/null
|
||||
PROCESSORS=$(find * -maxdepth 0 -type d)
|
||||
popd >/dev/null
|
||||
pushd $ROOT_DIR/applications/sink >/dev/null
|
||||
SINKS=$(find * -maxdepth 0 -type d)
|
||||
popd >/dev/null
|
||||
pushd $ROOT_DIR/applications/source >/dev/null
|
||||
SOURCES=$(find * -maxdepth 0 -type d)
|
||||
popd >/dev/null
|
||||
|
||||
for app in ${PROCESSORS[@]}; do
|
||||
APP_NAME="$app-$BROKER"
|
||||
DOWNLOAD=true
|
||||
if [ "$FILTER" != "" ]; then
|
||||
if [[ "$APP_NAME" == *"$FILTER"* ]]; then
|
||||
DOWNLOAD=true
|
||||
else
|
||||
DOWNLOAD=false
|
||||
fi
|
||||
fi
|
||||
if [ "$DOWNLOAD" == "true" ]; then
|
||||
APP_PATH="$ROOT_DIR/applications/processor/$app/apps/$app-$BROKER/target"
|
||||
TARGET_FILE="$APP_PATH/$app-$BROKER-$TAG.jar"
|
||||
if [ -f "$TARGET_FILE" ]; then
|
||||
pack build \
|
||||
--path "$TARGET_FILE" \
|
||||
--builder gcr.io/paketo-buildpacks/builder:base \
|
||||
--env BP_JVM_VERSION=$v "springcloudstream/$APP_NAME:$TAG"
|
||||
echo "Created springcloudstream/$APP_NAME:$TAG"
|
||||
else
|
||||
echo "Cannot find $TARGET_FILE won't attempt to create container"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
for app in ${SINKS[@]}; do
|
||||
APP_NAME="$app-$BROKER"
|
||||
DOWNLOAD=true
|
||||
if [ "$FILTER" != "" ]; then
|
||||
if [[ "$APP_NAME" == *"$FILTER"* ]]; then
|
||||
DOWNLOAD=true
|
||||
else
|
||||
DOWNLOAD=false
|
||||
fi
|
||||
fi
|
||||
if [ "$DOWNLOAD" == "true" ]; then
|
||||
APP_PATH="$ROOT_DIR/applications/sink/$app/apps/$app-$BROKER/target"
|
||||
TARGET_FILE="$APP_PATH/$app-$BROKER-$TAG.jar"
|
||||
if [ -f "$TARGET_FILE" ]; then
|
||||
pack build \
|
||||
--path "$TARGET_FILE" \
|
||||
--builder gcr.io/paketo-buildpacks/builder:base \
|
||||
--env BP_JVM_VERSION=$v "springcloudstream/$APP_NAME:$TAG"
|
||||
echo "Created springcloudstream/$APP_NAME:$TAG"
|
||||
else
|
||||
echo "Cannot find $TARGET_FILE won't attempt to create container"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
for app in ${SOURCES[@]}; do
|
||||
APP_NAME="$app-$BROKER"
|
||||
DOWNLOAD=true
|
||||
if [ "$FILTER" != "" ]; then
|
||||
if [[ "$APP_NAME" == *"$FILTER"* ]]; then
|
||||
DOWNLOAD=true
|
||||
else
|
||||
DOWNLOAD=false
|
||||
fi
|
||||
fi
|
||||
if [ "$DOWNLOAD" == "true" ]; then
|
||||
APP_PATH="$ROOT_DIR/applications/source/$app/apps/$app-$BROKER/target"
|
||||
TARGET_FILE="$APP_PATH/$app-$BROKER-$TAG.jar"
|
||||
if [ -f "$TARGET_FILE" ]; then
|
||||
pack build \
|
||||
--path "$TARGET_FILE" \
|
||||
--builder gcr.io/paketo-buildpacks/builder:base \
|
||||
--env BP_JVM_VERSION=$v "springcloudstream/$APP_NAME:$TAG"
|
||||
echo "Created springcloudstream/$APP_NAME:$TAG"
|
||||
else
|
||||
echo "Cannot find $TARGET_FILE won't attempt to create container"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
Reference in New Issue
Block a user