Page History
Table of Contents |
---|
Introduction
- Users can build their own Docker images for Agents.
- This article explains options how to create the Agent image.
Dockerfile
Docker images for JS7 Agents provided by SOS make use of the following Dockerfile:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
FROM openjdk:8-jre-alpine LABEL maintainer="Software- und Organisations-Service GmbH" # BUILD SETTINGS # provide build arguments for release information ARG JS_MAJOR ARG JS_RELEASE # default user id has to match later run-time user ARG JS_USER_ID=${UID:-1001} ARG JS_HTTP_PORT=${JS_HTTP_PORT:-4445} ARG JS_HTTPS_PORT=${JS_HTTPS_PORT:-4443} ARG JS_JAVA_OPTIONS=${JS_JAVA_OPTIONS} # RUN-TIME SETTINGS # JS7 JobScheduler ports and Java options ENV RUN_JS_HTTP_PORT=${RUN_JS_HTTP_PORT:-$JS_HTTP_PORT} ENV RUN_JS_HTTPS_PORT=${RUN_JS_HTTPS_PORT} ENV RUN_JS_JAVA_OPTIONS=${RUN_JS_JAVA_OPTIONS:-$JS_JAVA_OPTIONS} # PREPARATION # install process tools, bash RUN apk add --no-cache procps && \ apk add --no-cache bash # setup working directory RUN mkdir -p /var/sos-berlin.com/js7 WORKDIR /var/sos-berlin.com/js7 # add installation tarball ADD https://download.sos-berlin.com/Job Scheduler.${JS_MAJOR}/js7_agent_unix.${JS_RELEASE}.tar.gz /usr/local/src/ # INSTALLATION # extract tarball # for JDK < 12, /dev/random does not provide sufficient entropy, see https://kb.sos-berlin.com/x/lIM3 RUN test -e /usr/local/src/js7_agent_unix.${JS_RELEASE}.tar.gz && \ tar xfvz /usr/local/src/js7_agent_unix.${JS_RELEASE}.tar.gz -C /var/sos-berlin.com/js7 && \ rm /usr/local/src/js7_agent_unix.${JS_RELEASE}.tar.gz && \ sed -i 's/securerandom.source=file:\/dev\/random/securerandom.source=file:\/dev\/urandom/g' /usr/lib/jvm/java-1.8-openjdk/jre/lib/security/java.security # CONFIGURATION # copy configuration COPY config/ /var/sos-berlin.com/js7/agent/var_$JS_HTTP_PORT/config/ # add start script COPY start-agent.sh /usr/local/bin/ # Alpine: make default user the owner of directories RUN adduser -u ${JS_USER_ID:-1001} --disabled-password --home /home/jobscheduler --no-create-home --shell /bin/bash jobscheduler jobscheduler && \ chown -R jobscheduler:jobscheduler /var/sos-berlin.com && \ chmod +x /usr/local/bin/start-agent.sh # CODA # run-time user, can be overwritten when running the container USER jobscheduler # allow incoming traffic to port EXPOSE $RUN_JS_HTTP_PORT $RUN_JS_HTTPS_PORT CMD ["sh","-c","/usr/local/bin/start-agent.sh --http-port=$RUN_JS_HTTP_PORT --https-port=$RUN_JS_HTTPS_PORT --java-options=\"$RUN_JS_JAVA_OPTIONS\""] |
Build Script
The build script offers a number of options to parameterize the Dockerfile:
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:
- x
Overview
Content Tools