Page History
...
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 SchedulerJobScheduler.${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\""] |
...
- Line 8 - 9: The release identification is injected by build arguments. This information is used to determine the tarball to be downloaded with line 35
- Line 12 - 15: Defaults for the user id running the Agent inside the container as well as HTTP and HTTPS ports are provided. These values can be overwritten by providing the respective build arguments.
- Line 20 - 22: Environment variables are provided at run-time, not at build-time. They can be used to specify ports and Java options when running the container.
- Line 50: if a
config
folder is available in the build folder then its contents is copied to the respectiveconfig
folder in the container. This can be used to create an image with updated configuration files, see JS7 - Agent Configuration Items. Line 53: The start-agent.sh script is copied from the build folder to the container. Users can apply their own version of the start script. The start script used by SOS looks like this:
Code Block language bash title Agent Start Script linenumbers true collapse true #!/bin/sh js_http_port="" js_https_port="" js_java_options="" for option in "$@" do case "$option" in --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=//'` ;; *) echo "unknown argument: $option" exit 1 ;; esac done js_args="" if [ ! "$js_http_port" = "" ] then js_args="$js_args --http-port=$js_http_port" fi if [ ! "$js_https_port" = "" ] then js_args="$js_args --https-port=$js_https_port" fi if [ ! "$js_java_options" = "" ] then js_args="$js_args --java-options=$js_java_options" fi echo "starting Agent: /var/sos-berlin.com/js7/agent/bin/agent.sh start $js_args" /var/sos-berlin.com/js7/agent/bin/agent.sh start $js_args && tail -f /dev/null
- Line 56 - 58: The user account
jobscheduler
is created and is assigned the user id and group id handed over by the respective build argument. This translates to the fact that the account running the Agent inside the container and the account that starts the container are assigned the same user id and group id. This allows the account running the container to access any files created by the Agent in mounted volumes with identical permissions. - Line 66: The HTTP and optionally the HTTPS port that are forwarded by environment variables when running the container are exposed to the Docker host. This is relevant only if users wanted to use ports inside the container that are different from the default values. In most situations the default ports should be fine and are mapped to outside ports on the Docker host when starting the container.
- Line 68: The start script is executed and is dynamically parameterized from environment variables that are forwarded when starting the container.
...
Overview
Content Tools