Page History
...
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
#!/bin/sh set -e SCRIPT_HOME=$(dirname "$0") SCRIPT_HOME="`cd \"${SCRIPT_HOME}\" >/dev/null && pwd`" SCRIPT_FOLDER="`basename $(dirname "$SCRIPT_HOME")`" IMAGE_NAME="$(basename "$SCRIPT_HOME")" REPOSITORY_NAME="sosberlin/js7" # ----- modify default settings ----- JS_MAJOR_DEFAULT="2.0" JS_RELEASE_DEFAULT="2.0.0" JS_USER_ID_DEFAULT="$UID" JS_NETWORK_DEFAULT="js7" JS_HTTP_PORT_DEFAULT="4445" JS_HTTPS_PORT_DEFAULT="4443" JS_JAVA_OPTIONS_DEFAULT="-Xmx500m" JS_BUILD_ARGS_DEFAULT="" # ----- modify default settings ----- for option in "$@" do case "$option" in --network=*) JS_NETWORK=`echo "$option" | sed 's/--network=//'` ;; --http-port=*) JS_HTTP_PORT=`echo "$option" | sed 's/--http-port=//'` ;; --https-port=*) JS_HTTPS_PORT=`echo "$option" | sed 's/--https-port=//'` ;; --java-options=*) JS_JAVA_OPTIONS=`echo "$option" | sed 's/--java-options=//'` ;; --build-args=*) JS_BUILD_ARGS=`echo "$option" | sed 's/--build-args=//'` ;; *) echo "unknown argument: $option" exit 1 ;; esac done JS_MAJOR="${JS_MAJOR:-$JS_MAJOR_DEFAULT}" JS_RELEASE="${JS_RELEASE:-$JS_RELEASE_DEFAULT}" JS_USER_ID="${JS_USER_ID:-$JS_USER_ID_DEFAULT}" JS_NETWORK="${JS_NETWORK:-$JS_NETWORK_DEFAULT}" JS_HTTP_PORT="${JS_HTTP_PORT:-$JS_HTTP_PORT_DEFAULT}" JS_HTTPS_PORT="${JS_HTTPS_PORT:-$JS_HTTPS_PORT_DEFAULT}" JS_JAVA_OPTIONS="${JS_JAVA_OPTIONS:-$JS_JAVA_OPTIONS_DEFAULT}" JS_BUILD_ARGS="${JS_BUILD_ARGS:-$JS_BUILD_ARGS_DEFAULT}" set -x docker build --no-cache --rm \ --tag=$REPOSITORY_NAME:$IMAGE_NAME \ --file=$SCRIPT_HOME/build/Dockerfile \ --network=$JS_NETWORK \ --build-arg="JS_MAJOR=$JS_MAJOR" \ --build-arg="JS_RELEASE=$JS_RELEASE" \ --build-arg="JS_USER_ID=$JS_USER_ID" \ --build-arg="JS_HTTP_PORT=$JS_HTTP_PORT" \ --build-arg="JS_HTTPS_PORT=$JS_HTTPS_PORT" \ --build-arg="JS_JAVA_OPTIONS=$JS_JAVA_OPTIONS" \ $JS_BUILD_ARGS $SCRIPT_HOME/build set +x |
Explanations:
Line 9 - 10: The image name is determined from the name of the current directory. The repository name holds the owner and name of the repo separated by a slash.
- Line 13 - 27: Default values are specified that are used if no command line arguments are provided. This includes values for
- the release number: adjust this value to a current release of JS7.
- the user id: by default the user id of the user running the build script is used.
- the Docker network: the build script assumes a Docker network to be used for which the name is specified.
- the HTTP port and HTTPS port: if the respective port is not specified then the Agent will not listen to a port for the respective protocol. You can for example disable the HTTP protocol by specifying an empty value. The default inside ports should be fine as they are mapped by the run script to outside ports on the Docker host. However, you can modify the ports as you like.
- Java options: typically you would specify default values e.g. for Java memory consumption. The Java options can be overwritten by the run script, however, you might want to create your own image with adjusted default values.
- Line 30 - 47: The above options can be overwritten by command line arguments:
Code Block language bash title Running the Build Script with Arguments linenumbers true ./build.sh --network=js --http-port=14445 --https-port=14443 --java-options="-Xmx1G"
- Line 50 - 58: If command line arguments have been used then they are used instead of default values.
- Line 62 - 72: The effective
docker build
command is executed with arguments. The Dockerfile is assumed to be located with thebuild
sub-directory of the current directory.Status colour Yellow title TBD
Overview
Content Tools