Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagebash
titleDockerfile for Agent Image
linenumberstrue
collapsetrue
# BUILD PRE-IMAGE

FROM alpine:latest AS js7-pre-image

# provide build arguments for release information
ARG JS_RELEASE
ARG JS_RELEASE_MAJOR
ARG JS_HTTP_PORT=${JS_HTTP_PORT:-4445}

# add/copy tarball
ADD https://download.sos-berlin.com/JobScheduler.${JS_RELEASE_MAJOR}/js7_agent_unix.${JS_RELEASE}.tar.gz /usr/local/src/
# COPY js7_agent_unix.${JS_RELEASE}.tar.gz /usr/local/src/

RUN mkdir -p /var/sos-berlin.com/js7 && \
    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

# add entrypoint script and start script
COPY entrypoint.sh /var/sos-berlin.com/js7/
COPY start-agent.sh /var/sos-berlin.com/js7/

# copy default configuration
COPY config/ /var/sos-berlin.com/js7/agent/var_$JS_HTTP_PORT/config/

# BUILD IMAGE

FROM alpine:latest AS js7-image

LABEL maintainer="Software- und Organisations-Service GmbH"

# provide build arguments for release information
ARG JS_RELEASE
ARG JS_RELEASE_MAJOR

# default user id has to match later run-time user
ARG JS_USER_ID=${UID:-1001}
ARG JS_HTTP_INTERFACE=${JS_HTTP_INTERFACE:-""}
ARG JS_HTTP_PORT=${JS_HTTP_PORT:-4445}
ARG JS_HTTPS_INTERFACE=${JS_HTTPS_INTERFACE:-""}
ARG JS_HTTPS_PORT=${JS_HTTPS_PORT:-""}
ARG JS_JAVA_OPTIONS=${JS_JAVA_OPTIONS}

# JS7 JobScheduler user id, ports and Java options
ENV RUN_JS_USER_ID=${RUN_JS_USER_ID:-1001}
ENV RUN_JS_HTTP_INTERFACE=${RUN_JS_HTTP_INTERFACE:-$JS_HTTP_INTERFACE}
ENV RUN_JS_HTTP_PORT=${RUN_JS_HTTP_PORT:-$JS_HTTP_PORT}
ENV RUN_JS_HTTPS_INTERFACE=${RUN_JS_HTTPS_INTERFACE:-$JS_HTTPS_INTERFACE}
ENV RUN_JS_HTTPS_PORT=${RUN_JS_HTTPS_PORT}
ENV RUN_JS_JAVA_OPTIONS=${RUN_JS_JAVA_OPTIONS:-$JS_JAVA_OPTIONS}

COPY --from=js7-pre-image ["/var/sos-berlin.com/js7", "/var/sos-berlin.com/js7"]

# INSTALLATION

# install process tools, net tools, bash, openjdk
# for JDK < 12, /dev/random does not provide sufficient entropy, see https://kb.sos-berlin.com/x/lIM3
# make default user the owner of directories
RUN apk update && apk add --no-cache \
    --repository=http://dl-cdn.alpinelinux.org/alpine/edge/community \
    procps \
    net-tools \
    bash \
    openjdk8 && \
    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 && \
    mv /var/sos-berlin.com/js7/start-agententrypoint.sh /usr/local/bin/ && \
    mv /var/sos-berlin.com/js7/start-agent.sh /usr/local/bin/ && \
    chmod +x /usr/local/bin/entrypoint.sh /usr/local/bin/start-agent.sh && \
    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

# CODAMULTI-STAGE BUILDS

# run-time user, can be overwritten when running the container
USER jobscheduler

CMD<powershell>

# START

ENTRYPOINT ["sh","-c", "/usr/local/bin/entrypoint.sh"]

CMD ["/usr/local/bin/start-agent.sh", "--http-port=$RUN_JS_HTTP_INTERFACE:$RUN_JS_HTTP_PORT", "--https-port=$RUN_JS_HTTPS_INTERFACE:$RUN_JS_HTTPS_PORT", "--java-options=\"$RUN_JS_JAVA_OPTIONS\""]

...