Versions Compared

Key

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

...

  • joc
    • build.sh
    • build
      • Dockerfile
      • hibernate.cfg.xml
      • https-keytore.p12
      • https-truststore.p12
      • joc_install.xml
      • joc.properties.add
      • start.ini.add
      • start-joc.sh
      • config

...

Code Block
languagebash
titleDockerfile for JOC Cockpit Image
linenumberstrue
collapsetrue
FROM openjdk:8-jre-alpine

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

# BUILD SETTINGS

# 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=${JS_USER_ID:-1001}
ARG JS_HTTP_PORT=${JS_HTTP_PORT:-4446}
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:-$JS_HTTPS_PORT}
ENV RUN_JS_JAVA_OPTIONS=${RUN_JS_JAVA_OPTIONS:-$JS_JAVA_OPTIONS}

# PREPARATION

# install process tools, net tools, bash, vi
RUN apt-getapk update && \
apk add --no-cache \
 apt-get install -y procps && \
    apt-get install -y net-tools && \
    apt-get install -y bash && \
    apt-get install -y vim-tiny

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

# INSTALLATION

# extract installer 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_joc_linux.${JS_RELEASE}.tar.gz && \
    tar zxvf /usr/local/src/js7_joc_linux.${JS_RELEASE}.tar.gz -C /usr/local/src/ && \
    rm -f /usr/local/src/js7_joc_linux.${JS_RELEASE}.tar.gz && \
    ln -s /usr/local/src/joc.${JS_RELEASE} /usr/local/src/joc && \
    sed -i 's/securerandom.source=file:\/dev\/random/securerandom.source=file:\/dev\/urandom/g' /usr/local/openjdk-8/lib/security/java.security

# copy installer response file, hibernate configuration file and start script
COPY joc_install.xmladd keystore and truststore for private keys and certificates
COPY https-keystore.p12 /tmp
COPY https-truststore.p12 /tmp

# add keystore and truststore locations to configuration files
COPY start.ini.add /tmp/
COPY joc.properties.add /tmp/

# copy installer response file and start script
COPY joc_install.xml /tmp
COPY start-joc.sh /usr/local/bin/

# INSTALLATION

# extract installer tarball
# for JDK < 12, /dev/random does not provide sufficient entropy, see https://kb.sos-berlin.com/x/lIM3
# substitute build arguments in installer response file
# add jobscheduler user account and group
# run setup
# add keystore and truststore locations to configuration files
# enable https module
# add keystore and truststore for private keys and certificates
RUN test -e /usr/local/src/joc/
COPY hibernate.cfg.xml /js7_joc_linux.${JS_RELEASE}.tar.gz && \
    tar zxvf /usr/local/src/joc/
COPY start-joc.shjs7_joc_linux.${JS_RELEASE}.tar.gz -C /usr/local/binsrc/

# substitute build arguments in installer response file
RUN sed -i "s/\s*<entry\s*key\s*=\"jettyPort\".*\/>/<entry key=\"jettyPort\" value=\"$JS_HTTP_PORT\"\/>/g" && \
    rm -f /usr/local/src/js7_joc_linux.${JS_RELEASE}.tar.gz && \
    ln -s /usr/local/src/joc.${JS_RELEASE} /usr/local/src/joc && \
    mv /tmp/joc_install.xml /usr/local/src/joc/joc_install.xml

# perform installation, add jobscheduler user account
RUN groupadd --gid ${JS_USER_ID:-1001} jobscheduler  && \
    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 && \
    useraddsed --uid ${JS_USER_ID:-1001} --gid jobscheduler --home-dir /home/jobscheduler --no-create-home --shell /bin/bash jobscheduler && \
    cd i "s/\s*<entry\s*key\s*=\"jettyPort\".*\/>/<entry key=\"jettyPort\" value=\"$JS_HTTP_PORT\"\/>/g" /usr/local/src/joc && ./setup.sh -u joc_install.xml && \
    chmod +x /usr/local/bin/start-joc.sh

# CONFIGURATION

# enable https module
RUN  java -jar "/opt/sos-berlin.com/js7/joc/jetty/start.jar" -Djetty.home="/opt/sos-berlin.com/js7/joc/jetty" -Djetty.base="adduser -u ${JS_USER_ID:-1001} --disabled-password --home /home/jobscheduler --no-create-home --shell /bin/bash jobscheduler jobscheduler && \
    cd /usr/local/src/joc && ./setup.sh -u joc_install.xml && \
    cat /tmp/start.ini.add >> /var/sos-berlin.com/js7/joc" --add-to-start=https

# add keystore and truststore for private keys and certificates
COPY https-keystore.p12/start.ini && \
    sed -i "s/\s*jetty.ssl.port\s*=.*/jetty.ssl.port=$JS_HTTPS_PORT/g" /var/sos-berlin.com/js7/joc/resources/joc/
COPY https-truststore.p12start.ini && \
    cat /tmp/joc.properties.add >> /var/sos-berlin.com/js7/joc/resources/joc/

# add keystore and truststore locations to configuration files
COPY start.ini.add /tmp/
COPY joc.properties.add /tmp/
RUN  cat /tmp/start.ini.add >> /varjoc.properties && \
    java -jar "/opt/sos-berlin.com/js7/joc/jetty/start.jar" -Djetty.home="/opt/sos-berlin.com/js7/joc/start.ini && \
     sed -i "s/\s*jetty.ssl.port\s*=.*/jetty.ssl.port=$JS_HTTPS_PORT/g" jetty" -Djetty.base="/var/sos-berlin.com/js7/joc/start.ini" --add-to-start=https && \
     catmv /tmp/joc.properties.add >>https-keystore.p12 /var/sos-berlin.com/js7/joc/resources/joc/joc.properties

# copy configuration
COPY config/ && \
    mv /tmp/https-truststore.p12 /var/sos-berlin.com/js7/joc/resources/

# make jobscheduler user account the owner of directories
RUN/joc/ && \
    chmod +x /usr/local/bin/start-joc.sh && \
    chown -R jobscheduler:jobscheduler /var/sos-berlin.com

# CODACONFIGURATION

# allowcopy incomingconfiguration
# trafficCOPY to ports
EXPOSE $RUN_JS_HTTP_PORT $RUN_JS_HTTPS_PORTconfig/ /var/sos-berlin.com/js7/joc/resources/

# CODA

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

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

...

  • Line 1: The base image is OpenJDK Java 1.8 (Debian based). You can run JOC Cockpit with newer Java releases, however, stick to Oracle, OpenJDK or AdoptOpenJDK as the source for your Java base image. Alternatively you can use your own base image and install Java 1.8 on top of this. Consider that availability of JDBC Drivers can limit the Java version to be used.
  • Line 8 - 9: The release identification is injected by build arguments. This information is used to determine the tarball to be downloaded.
  • Line 12 - 15: Defaults for the user id running the JOC Cockpit 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 27 - 31: The image OS is updated and additional packages are installed (ps, netstat, bash, vi).
  • Line 34 - 35: You can either download the JOC Cockpit tarball directly from the SOS web site or you store the tarball with the build directory and copy from this location.
  • Line 48: the joc_install.xml response file is copied to the image. This file includes settings for headless installation of JOC Cockpit, see JS7 - JOC Cockpit Installation On Premises. In fact when building the image a JOC Cockpit installation is performed.

    Code Block
    languagexml
    titleJOC Cockpit Installer Response File
    linenumberstrue
    collapsetruetrue
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <!--
         XML configuration file for JOC
    
    If you call the installer with this XML file then
    you accept at the same time the terms of the
    licence agreement under GNU GPL 2.0 License
    (see http://www.gnu.org/licenses/gpl-2.0.html)
    -->
    <AutomatedInstallation langpack="eng">
        <com.izforge.izpack.panels.UserInputPanel id="home">
            <userInput/>
        </com.izforge.izpack.panels.UserInputPanel>
        <com.izforge.izpack.panels.HTMLLicencePanel id="gpl_licence"/>
        <com.izforge.izpack.panels.TargetPanel id="target">
    
            <!-- SELECT THE INSTALLATION PATH
                              It must be absolute!
                 For example:
                 /opt/sos-berlin.com/joc on Linux
                 C:\Program Files\sos-berlin.com\joc on Windows -->
            <installpath>/opt/sos-berlin.com/js7/joc</installpath>
    
        </com.izforge.izpack.panels.TargetPanel>
        <com.izforge.izpack.panels.UserInputPanel id="jetty">
            <userInput>
    
                <!-- JOC requires a servlet container such as Jetty.
                                      If a servlet container already installed then you can use it.
       <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <!--
         XML configuration file for JOC
    
    If you call the installer with this XML file then
    you accept at the same time the terms of the
    licence agreement under GNU GPL 2.0 License
    (see http://www.gnu.org/licenses/gpl-2.0.html)
    -->
    <AutomatedInstallation langpack="eng">
        <com.izforge.izpack.panels.UserInputPanel id="home">
            <userInput/>
         </com.izforge.izpack.panels.UserInputPanel>
        <com.izforge.izpack.panels.HTMLLicencePanel id="gpl_licence"/>
        <com.izforge.izpack.panels.TargetPanel id="target">
    
     Otherwise a Jetty will be installed in addition if withJettyInstall=yes.
            <!-- SELECT THE INSTALLATION PATH
         You need root permissions to install JOC with Jetty. -->
                It must be absolute!<entry key="withJettyInstall" value="yes"/>
                <entry For example:key="jettyPort" value="4446"/>
                 /opt/sos-berlin.com/joc on Linux
                 C:\Program Files\sos-berlin.com\joc on Windows -->
     <!-- Specify the name of the Windows service or Linux Daemon (default: joc).
           <installpath>/opt/sos-berlin.com/js7/joc</installpath>
    
        </com.izforge.izpack.panels.TargetPanel>
        <com.izforge.izpack.panels.UserInputPanel id="jetty">
            <userInput>
    
               Only <!-- JOC requires a servlet container such as Jetty.necessary for multiple instances of JOC on one server. It must be
                     unique per server. This entry is deactivated by a comment because it
           If a servlet container already installed then you can use it.
              MUST NOT BE CHANGED DURING OVER-INSTALLATION! -->
                <!--
             Otherwise a Jetty will be installed in addition if withJettyInstall=yes.
               <entry key="jettyServiceName" value="joc"/>
        You need root permissions to install JOC with Jetty. -->
                <entry key="withJettyInstall" value="yes"/<!-- Only necessary for Windows -->
                <entry key="jettyPortjettyStopPort" value="444644446"/>
                <!-- Specify the name of the Windows service or Linux Daemon (default: joc).
              Only necessary for Unix (root permissions required) -->
                <entry key="withJocInstallAsDaemon" value="yes"/>
              Only necessary for multiple instances of<!-- To enter a JOC on one server. It must be
    User (default=current User).
                        unique per server. This entry is deactivated by a comment because it
       For Unix only (root permissions required)!!! -->
            MUST NOT BE CHANGED DURING OVER-INSTALLATION! --<entry key="runningUser" value="jobscheduler"/>
                <!--
     Path to Jetty base directory
                            <entry key="jettyServiceName" value="joc"/>
                -->For example:
                <!-- Only necessary for Windows -->
       /home/[user]/sos-berlin.com/joc on Linux
              <entry key="jettyStopPort" value="44446"/>
                <!-- Only necessary for Unix (root permissions required)C:\ProgramData\sos-berlin.com\joc on Windows -->
                <entry key="withJocInstallAsDaemonjettyBaseDir" value="yes/var/sos-berlin.com/js7/joc"/>
    
                <!-- ToChoose enter(yes a JOC User (default=current User).
                                      For Unix only (root permissions required)!!!or no) wether the JOC's Jetty should be (re)started at the end of the installation -->
                <entry key="runningUserlaunchJetty" value="jobschedulerno"/>
    
                <!-- PathJava options tofor Jetty base directory. -->
                <!-- Initial memory pool (-Xms) in                 For example:MB -->
                <entry     /home/[user]/sos-berlin.com/joc on Linuxkey="jettyOptionXms" value="128"/>
                <!-- Maximum memory   C:\ProgramData\sos-berlin.com\joc on Windowspool (-Xmx) in MB -->
                <entry key="jettyBaseDirjettyOptionXmx" value="/var/sos-berlin.com/js7/joc512"/>
    
                <!-- ChooseThread (yes or no) wether the JOC's Jetty should be (re)started at the end of the installation stack size (-Xss) in KB -->
                <entry key="launchJettyjettyOptionXss" value="no4000"/>
    
                <!-- Further Java options for Jetty. -->
                <!-- Initial memory pool (-Xms) in MB -->
    <entry key="jettyOptions" value=""/>
    
            </userInput>
        </com.izforge.izpack.panels.UserInputPanel>
       <entry key="jettyOptionXms" value="128"/>
     <com.izforge.izpack.panels.UserInputPanel id="joc">
            <userInput>
    
         <!-- Maximum memory pool (-Xmx) in MB <!-->
                <entry key="jettyOptionXmx" value="512"/>
     JOC can be installed in a cluster. Please type a unique title to identify the cluster node,
                 <!-- Thread stack size (-Xss) in KB    e.g. hostname. Max. length is 30 characters -->
                <entry key="jettyOptionXssjocTitle" value="4000PRIMARY JOC COCKPIT"/>
    
                <!-- Further Java options Choose yes if JOC is a standby node in a cluster -->
                <entry key="jettyOptionsisStandby" value="no"/>
    
            </userInput>
        </com.izforge.izpack.panels.UserInputPanel>
        <com.izforge.izpack.panels.UserInputPanel id="joc">
            <userInput>
    
    !-- Security Level for the signing mechanism: possibly values are 'LOW', 'MEDIUM' and 'HIGH'
                    <!-- JOC can be installed in a cluster. Please type a unique title to identify the cluster node,
     HIGH:
                        public PGP keys are stored for verification only
          e.g. hostname. Max. length is 30 characters -->
           all signing will be done <entry key="jocTitle" value="PRIMARYexternally outside of JOC COCKPIT"/>
    
    Cockpit
                  <!-- Choose yes ifMEDIUM:
     JOC is a standby node in a cluster -->
               a <entry key="isStandby" value="no"/>
    
    private PGP key will be stored for signing
                   <!-- Security Level for the signing mechanism:will possiblybe valuesdone are 'LOW', 'MEDIUM' and 'HIGH'automatically with the provided key
                     HIGHLOW:
                        public PGPno keys are stored for verification only
     will be stored
                       all signing will be done externallyinternally outsidewith ofdefault JOCkeys Cockpit-->
                <entry key="securityLevel" value="LOW"/>
    
       MEDIUM:     </userInput>
        </com.izforge.izpack.panels.UserInputPanel>
        <com.izforge.izpack.panels.UserInputPanel id="database">
            <userInput>
       a private PGP key will be stored for signing
     <!-- Reporting Database Configuration -->
    
                <!-- Database connection signingsettings willcan be donespecified automaticallywith withfollowing theentries providedsuch keyas
                     LOW:
                     databaseHost, databasePort, ... or noby keysa willhibernate beconfiguration storedfile
                     Posible values are signing will be done internally with default keys 'withoutHibernateFile' (default) and 'withHibernateFile'. -->
                <entry key="securityLeveldatabaseConfigurationMethod" value="LOWwithoutHibernateFile"/>
    
            </userInput>
        </com.izforge.izpack.panels.UserInputPanel>
        <com.izforge.izpack.panels.UserInputPanel id="database">
            <userInput>
      !-- Choose the database management system. Supported values are 'mysql' for MySQL,
              <!-- Reporting Database Configuration -->
    
                <!-- Database connection settings can be specified with following'oracle' entriesfor such as
           Oracle, 'mssql' for MS SQL Server, 'pgsql' for PostgreSQL.
    
                     Only if databaseConfigurationMethod=withoutHibernateFile -->
           databaseHost, databasePort, ... or by a hibernate configuration file<entry key="databaseDbms" value="mysql"/>
    
                <!-- Path to a hibernate Posibleconfiguration valuesfile are 'withoutHibernateFile' (default) and 'withHibernateFile'.if databaseConfigurationMethod=withHibernateFile -->
                <entry key="databaseConfigurationMethodhibernateConfFile" value="withHibernateFile"/>
    
                <!-- ChooseYou thecan databasechoose management system. Supported values are 'mysql' for MySQL,
       between 'on' or 'off' to create the database tables.
                     If you have modified the initial data of       'oracle' for Oracle, 'mssql' for MS SQL Server, 'pgsql' for PostgreSQL.
    
    an already existing installation,
                     then the modifications Onlywill if databaseConfigurationMethod=withoutHibernateFile -->
       be undone. Data added remains unchanged.
             <entry key="databaseDbms" value=""/>
    
          This entry should be only  <!-- Path to a hibernate configuration file if databaseConfigurationMethod=withHibernateFile'off', when you sure, that all tables are already created. -->
                <entry key="hibernateConfFiledatabaseCreateTables" value="hibernate.cfg.xmloff"/>
    
            </userInput>
        </com.izforge.izpack.panels.UserInputPanel>
        <com.izforge.izpack.panels.UserInputPanel id="dbconnection">
            <userInput>
                <!-- Database Configuration if databaseConfigurationMethod=withoutHibernateFile -->
    
                <!-- Enter the name or ip address of the database host
                                      This entry can also be used to configure the URL(s) for Oracle RAC databases.
                     For example:
                     <entry key="databaseHost" value="(DESCRIPTION=(ADDRESS_LIST=(LOAD_BALANCE=OFF)(FAILOVER=ON)
                        (ADDRESS=(PROTOCOL=TCP)(HOST=tst-db1.myco.com)(PORT=1604))
                        (ADDRESS=(PROTOCOL=TCP)(HOST=tst-db2.myco.com)(PORT=1604)))
                        (CONNECT_DATA=(SERVICE_NAME=mydb1.myco.com)(SERVER=DEDICATED)))"/>
                     The "databaseSchema" and "databasePort" entries should then be left empty. -->
                <entry key="databaseHost" value=""/>
    
                <!-- Enter the port number for the database instance. Default ports are for MySQL 3306,
                                      Oracle 1521, MS SQL Server 1433, postgreSQL 5432. -->
                <entry key="databasePort" value=""/>
    
                <!-- Enter the schema -->
                <entry key="databaseSchema" value=""/>
    
                <!-- Enter the user name for database access -->
                <entry key="databaseUser" value=""/>
    
                <!-- Enter the password for database access -->
                <entry key="databasePassword" value=""/>
    
            </userInput>
        </com.izforge.izpack.panels.UserInputPanel>
        <com.izforge.izpack.panels.UserInputPanel id="jdbc">
            <userInput>
                <!-- Database Configuration -->
    
                <!-- You can specify an external JDBC connector then set internalConnector = no
                                      For license reasons MySQL, MS SQL Server and Oracle ojdbc7 JDBC
                     drivers are not provided.
                     Alternatively you can use the mariadb JDBC Driver for MySQL and
                     the jTDS JDBC Driver for MS SQL Server which is provided.
                     An Oracle ojdbc6 JDBC driver is also provided. -->
    
                <!-- You can choose between 'yes' or 'no' for using the internal JDBC connector
                                      or not -->
    
                <entry key="internalConnector" value="yes"/>
    
                <!-- Select the path to JDBC Driver -->
                <entry key="connector" value=""/>
    
            </userInput>
        </com.izforge.izpack.panels.UserInputPanel>
        <com.izforge.izpack.panels.UserInputPanel id="end">
            <userInput/>
        </com.izforge.izpack.panels.UserInputPanel>
        <com.izforge.izpack.panels.InstallPanel id="install"/>
        <com.izforge.izpack.panels.ProcessPanel id="process"/>
        <com.izforge.izpack.panels.FinishPanel id="finish"/>
    </AutomatedInstallation>
  • Line 49: the hibernate.cfg.xml configuration file is copied that holds the database connection settings for JOC Cockpit. The database has to be available during build of the Docker image. Users can later on choose a different database connection by modifying/overwriting this file at run-time. For details about Hibernate configuration files see JS7 - Database.

    Code Block
    languagexml
    titleJOC Cockpit Hibernate Configuration for Database Access
    linenumberstrue
    collapsetrue
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <hibernate-configuration>
     <session-factory>
      <property name="hibernate.connection.driver_class">org.mariadb.jdbc.Driver</property>
      <property name="hibernate.connection.password">jobscheduler</property>
      <property name="hibernate.connection.url">jdbc:mysql://mysql-5-7:3306/js7_docker</property>
      <property name="hibernate.connection.username">jobscheduler</property>
      <property name="hibernate.dialect">org.hibernate.dialect.MySQLInnoDBDialect</property>
      <property name="hibernate.show_sql">false</property>
      <property name="hibernate.connection.autocommit">false</property>
      <property name="hibernate.format_sql">true</property>
      <property name="hibernate.temp.use_jdbc_metadata_defaults">false</property>
    
      <!-- Hikari Connection Pool -->
      <property name="hibernate.connection.provider_class">org.hibernate.hikaricp.internal.HikariCPConnectionProvider</property>
      <property name="hibernate.hikari.maximumPoolSize">10</property>
     </session-factory>
    </hibernate-configuration>
  • Line 50: The start-joc.sh script is copied from the build directory to the image. Users can apply their own version of the start script. The start script used by SOS looks like this:

    Code Block
    languagebash
    titleJOC Cockpit Start Script
    linenumberstrue
    collapsetrue
    #!/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
      # enable http access
      sed -i "s/.*--module=http$/--module=http/g" /var/sos-berlin.com/js7/joc/start.ini
      # set port for http access
      sed -i "s/.*jetty.http.port\s*=.*/jetty.http.port=$js_http_port/g" /var/sos-berlin.com/js7/joc/start.ini
    else
      # disable http access
      sed -i "s/\s*--module=http$/# --module=http/g" /var/sos-berlin.com/js7/joc/start.ini
    fi
    
    if [ ! "$js_https_port" = "" ]
    then
      # enable https access
      sed -i "s/.*--module=https$/--module=https/g" /var/sos-berlin.com/js7/joc/start.ini
      # set port for https access
      sed -i "s/\s*jetty.ssl.port\s*=.*/jetty.ssl.port=$js_https_port/g" /var/sos-berlin.com/js7/joc/start.ini
    else
      # disable https access
      sed -i "s/\s*--module=https$/# --module=https/g" /var/sos-berlin.com/js7/joc/start.ini
    fi
    
    if [ ! -z "$js_java_options" ]
    then
      export JAVA_OPTIONS="${JAVA_OPTIONS} $js_java_options"
    fi
    
    echo "starting JOC Cockpit: /opt/sos-berlin.com/js7/joc/jetty/bin/jetty.sh start"
    /opt/sos-berlin.com/js7/joc/jetty/bin/jetty.sh start && tail -f /dev/null
  • Line 56 - 57: The user account jobscheduler is created and is assigned the user id and group id handed over by the respective build arguments. This translates to the fact that the account running the JOC Cockpit 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 JOC Cockpit in mounted volumes with identical permissions.
  • Line 58: The JOC Cockpit setup is performed.
  • Line 64: The Jetty servlet container is added the HTTPS module for use with JOC Cockpit.
  • Line 67 - 68: The default keystore and truststore is copied that hold the private key and certificate required for server authentication with HTTPS.
  • Line 71 - 75: The keystore and truststore locations are added to the Jetty start.ini file and joc.properties file respectively. 
    • start.ini.add is used for access e.g. by client browsers:

      Code Block
      languagebash
      titleJetty HTTPS Configuration File start.ini.add
      linenumberstrue
      collapsetrue
      ## Keystore file path (relative to $jetty.base)
      jetty.sslContext.keyStorePath=resources/joc/https-keystore.p12
      
      ## Truststore file path (relative to $jetty.base)
      jetty.sslContext.
      trustStorePath=resources/joc/https-truststore.p12
      
      ## Keystore password
      jetty.sslContext.keyStorePassword=jobscheduler
      
      ## KeyManager password (same as keystore password for pkcs12 keystore type)
      jetty.sslContext.keyManagerPassword=jobscheduler
      
      ## Truststore password
      jetty.sslContext.trustStorePassword=jobscheduler
      
      ## Connector port to listen on
      jetty.ssl.port=4443
    • joc.properties.add is used for connections to the Controller should such connections require HTTPS mutual authentication:

      Code Block
      languagebash
      titleJOC Cockpit configuration File joc.properties.add
      linenumberstrue
      collapsetrue
      ################################################################################
      ### Location, type and password of the Java truststore which contains the
      ### certificates of eachJobScheduler Controller for HTTPS connections. Path can be
      ### absolute or relative to this file.
      
      keystore_path = ../../resources/joc/https-keystore.p12
      keystore_type = PKCS12
      keystore_password = jobscheduler
      key_password = jobscheduler
      
      truststore_path = ../../resources/joc/https-truststore.p12
      truststore_type = PKCS12
      truststore_password = jobscheduler
      
      
  • Line 78: if a config folder is available in the build directory then its contents is copied to the respective config folder in the image. This can be useful to create an image with individual settings in configuration files, see JS7 - JOC Cockpit Configuration Items.
  • Line 86: The HTTP port and optionally the HTTPS port are exposed to the Docker host. Both ports can be forwarded by environment variables when running the container, overwriting the build-time values. This is relevant only if users want 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 91: The start script is executed and is dynamically parameterized from environment variables that are forwarded when starting the container.

...

Code Block
languagebash
titleBuild Script for JOC Cockpit Image
linenumberstrue
collapsetrue
#!/bin/sh

set -e

SCRIPT_HOME=$(dirname "$0")
SCRIPT_HOME="`cd "${SCRIPT_HOME}" >/dev/null && pwd`"
SCRIPT_FOLDER="`basename $(dirname "$SCRIPT_HOME")`"


# ----- modify defaltdefault settings -----

JS_RELEASE="2.0.0-SNAPSHOT"
JS_REPOSITORY="sosberlin/js7"
JS_IMAGE="$(basename "${SCRIPT_HOME}")-${JS_RELEASE//\./-}"

JS_USER_ID="$UID"
JS_NETWORK="js7$UID"

JS_HTTP_PORT="4446"
JS_HTTPS_PORT="4443"

JS_JAVA_OPTIONS="-Xmx128m"
JS_BUILD_ARGS=""

# ----- modify default settings -----


for option in "$@"
do
  case "$option" in
         --release=*)      JS_RELEASE=`echo "$option" | sed 's/--release=//'`
                           ;;
         --repository=*)   JS_REPOSITORY=`echo "$option" | sed 's/--repository=//'`
                           ;;
         --image=*)        JS_IMAGE=`echo "$option" | sed 's/--image=//'`
                           ;;
         --user-id=*)      JS_USER_ID=`echo "$option" | sed 's/--user-id=//'`
                           ;;
         --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

set -x

docker build --no-cache --rm \
      --tag=$JS_REPOSITORY:$JS_IMAGE \
      --file=$SCRIPT_HOME/build/Dockerfile \
      --network=$JS_NETWORK \
      --build-arg="JS_RELEASE=$JS_RELEASE" \
      --build-arg="JS_RELEASE_MAJOR=$(echo $JS_RELEASE | cut -d . -f 1,2)" \
      --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

...