Page History
...
joc
The joc
root directory can have any name. The build files listed above are available for download. Note that the build script described below will, by default, use the directory name and release number to determine the resulting image name.
...
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
# BUILD PRE-IMAGE FROM alpine:3.15 AS js7-pre-image # provide build arguments for release information ARG JS_RELEASE ARG JS_RELEASE_MAJOR # add installer archive file # 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/ 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 # copy installer response file, entrypoint script and start script COPY joc_install.xml /usr/local/src/ COPY entrypoint.sh /usr/local/src/ # copy configuration COPY config/ /usr/local/src/resources # BUILD IMAGE FROM alpine:3.15 AS js7-image LABEL maintainer="Software- und Organisations-Service GmbH" # provide build arguments for release information ARG JS_RELEASE ARG JS_RELEASE_MAJOR # image user id has to match later run-time user id 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} # JS7 user id, ports and Java options ENV RUN_JS_USER_ID=${RUN_JS_USER_ID:-1001} 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} COPY --from=js7-pre-image ["/usr/local/src", "/usr/local/src"] # INSTALLATION # install process tools, net tools, bash, openjdk # add jobscheduler user account and group # 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 # run setup RUN apk update && apk add --no-cache \ procps \ net-tools \ bash \ su-exec \ shadow \ git \ openjdk11 && \ sed -i 's/securerandom.source=file:\/dev\/random/securerandom.source=file:\/dev\/urandom/g' /usr/lib/jvm/java-11-openjdk/conf/security/java.security && \ sed -i 's/jdk.tls.disabledAlgorithms=SSLv3, RC4, DES, MD5withRSA, DH keySize < 1024, \\/jdk.tls.disabledAlgorithms=SSLv3, RC4, DES, MD5withRSA, DH keySize < 1024, TLSv1, TLSv1.1, \\/g' /usr/lib/jvm/java-11-openjdk/conf/security/java.security && \ adduser -u ${JS_USER_ID:-1001} --disabled-password --home /home/jobscheduler --shell /bin/bash jobscheduler jobscheduler && \ ln -s /usr/local/src/joc.${JS_RELEASE} /usr/local/src/joc && \ mv /usr/local/src/joc_install.xml /usr/local/src/joc/ && \ mv /usr/local/src/resources/hibernate.cfg.xml /usr/local/src/joc/ && \ sed -i "s/\s*<entry\s*key\s*=\"jettyPort\".*\/>/<entry key=\"jettyPort\" value=\"$JS_HTTP_PORT\"\/>/g" /usr/local/src/joc/joc_install.xml && \ cd /usr/local/src/joc && ./setup.sh -u joc_install.xml && \ mv /usr/local/src/entrypoint.sh /usr/local/bin/ && \ chmod +x /usr/local/bin/entrypoint.sh && \ mv /usr/local/src/resources/* /var/sos-berlin.com/js7/joc/resources/joc/ && \ cat /var/sos-berlin.com/js7/joc/resources/joc/start.ini.add >> /var/sos-berlin.com/js7/joc/start.ini && \ cat /var/sos-berlin.com/js7/joc/resources/joc/joc.properties.add >> /var/sos-berlin.com/js7/joc/resources/joc/joc.properties && \ sed -i "s/\s*jetty.ssl.port\s*=.*/jetty.ssl.port=$JS_HTTPS_PORT/g" /var/sos-berlin.com/js7/joc/resources/joc/start.d/ssl.ini && \ java -jar "/opt/sos-berlin.com/js7/joc/jetty/start.jar" -Djetty.home="/opt/sos-berlin.com/js7/joc/jetty" -Djetty.base="/var/sos-berlin.com/js7/joc" --add-to-startmodule=https && \ mvcp /var/sos-berlin.com/js7/joc/start.inid/* /var/sos-berlin.com/js7/joc/resources/joc/start.d/ && \ lnmv -s /var/sos-berlin.com/js7/joc/resources/joc/start.d/ssl.ini /var/sos-berlin.com/js7/joc/start.inid/ && \ chown -R jobscheduler:jobscheduler /var/sos-berlin.com # JDK 8 # openjdk8 && \ # 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 && \ # JDK 11 # openjdk11 && \ # sed -i 's/securerandom.source=file:\/dev\/random/securerandom.source=file:\/dev\/urandom/g' /usr/lib/jvm/java-11-openjdk/conf/security/java.security && \ # Patch for SQL Server JDBC Driver # COPY --chown=jobscheduler:jobscheduler mssql-jdbc-9.2.1.jre8.jar /var/sos-berlin.com/js7/joc/lib/ext/joc/ # Patch for Oracle JDBC Driver # COPY --chown=jobscheduler:jobscheduler ojdbc8-18.3.0.0.jar /var/sos-berlin.com/js7/joc/lib/ext/joc/ # Patch for PostgreSQL JDBC Driver # COPY --chown=jobscheduler:jobscheduler postgresql-42.2.19.jar /var/sos-berlin.com/js7/joc/lib/ext/joc/ # Patch for H2 JDBC Driver # COPY --chown=jobscheduler:jobscheduler h2-1.4.200.jar /var/sos-berlin.com/js7/joc/lib/ext/joc/ # license # COPY --chown=jobscheduler:jobscheduler js7-license.jar /var/sos-berlin.com/js7/joc/lib/ext/joc/ # START ENTRYPOINT ["/bin/sh", "-c", "/usr/local/bin/entrypoint.sh"] CMD ["/bin/sh", "-c", "/opt/sos-berlin.com/js7/joc/jetty/bin/jetty.sh", "start"] |
Explanation:
START
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"] |
Explanation:
- The build script implements two stages to exclude installer files from the resulting image.
- Line 3: The base image is the current Alpine image at build-time.
- Line 6 - 7: The release identification is injected by build arguments. This information is used to determine the tarball to be downloaded or copied.
- Line 10 - 11: You can either download the JOC Cockpit tarball directly from the SOS web site or you can store the tarball with the build directory and copy from this location.
Line 13 - 15: The tarball is extracted.
Line 18: the
joc_install.xml
response file is copied to the image. This file includes settings for headless installation of the JOC Cockpit, see JS7 - JOC Cockpit Installation On Premises. In fact a JOC Cockpit installation is performed when building the image.Code Block language xml title JOC Cockpit Installer Response File linenumbers true collapse true <?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. Otherwise a Jetty will be installed in addition if withJettyInstall=yes. You need root permissions to install JOC with Jetty. --> <entry key="withJettyInstall" value="yes"/> <entry key="jettyPort" value="4446"/> <!-- Specify the name of the Windows service or Linux Daemon (default: joc). Only necessary for multiple instances of JOC on one server. It must be unique per server. This entry is deactivated by a comment because it MUST NOT BE CHANGED DURING OVER-INSTALLATION! -->
- The build script implements two stages to exclude installer files from the resulting image.
- Line 3: The base image is the current Alpine image at build-time.
- Line 6 - 7: The release identification is injected by build arguments. This information is used to determine the tarball to be downloaded or copied.
- Line 10 - 11: You can either download the JOC Cockpit tarball directly from the SOS web site or you can store the tarball with the build directory and copy from this location.
Line 13 - 15: The tarball is extracted.
Line 18: the
joc_install.xml
response file is copied to the image. This file includes settings for headless installation of the JOC Cockpit, see JS7 - JOC Cockpit Installation On Premises. In fact a JOC Cockpit installation is performed when building the image.Code Block language xml title JOC Cockpit Installer Response File linenumbers true collapse true <?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 <entry It must be absolute!key="jettyServiceName" value="joc"/> For example:--> /opt/sos-berlin.com/joc on Linux <!-- Only necessary for Windows --> C:\Program Files\sos-berlin.com\joc on Windows -- <entry key="jettyStopPort" value="44446"/> <installpath>/opt/sos-berlin.com/js7/joc</installpath> </com.izforge.izpack.panels.TargetPanel> <com.izforge.izpack.panels.UserInputPanel id="jetty"> !-- Only necessary for Unix (root permissions required) --> <userInput> <entry key="withJocInstallAsDaemon" value="yes"/> <!-- JOCTo requiresenter a servletJOC container such as JettyUser (default=current User). IfFor a servlet container already installed then you can use it.Unix only (root permissions required)!!! --> <entry key="runningUser" value="jobscheduler"/> Otherwise a Jetty will be installed in addition if withJettyInstall=yes. <!-- Path to Jetty base directory You need root permissions to install JOC with Jetty. --> <entry key="withJettyInstall" value="yes"/>For example: <entry key="jettyPort" value="4446"/> /home/[user]/sos-berlin.com/joc on Linux <!-- Specify the name of the Windows service or Linux Daemon (default: joc). C:\ProgramData\sos-berlin.com\joc on Windows --> <entry key="jettyBaseDir" value="/var/sos-berlin.com/js7/joc"/> <!-- Choose (yes or no) Only necessary for multiple instances of JOC on one server. It must be wether the JOC's Jetty should be (re)started at the end of the installation --> unique per server. This entry is deactivated by a comment because it <entry key="launchJetty" value="no"/> <!-- Java options for Jetty. --> MUST NOT BE CHANGED DURING OVER-INSTALLATION<! --> Initial memory pool (-Xms) in MB <!--> <entry key="jettyOptionXms" value="128"/> <!-- Maximum memory pool (-Xmx) <entry key="jettyServiceName" value="joc"/> in MB --> --<entry key="jettyOptionXmx" value="512"/> <!-- Thread Only necessary for Windowsstack size (-Xss) in KB --> <entry key="jettyStopPortjettyOptionXss" value="444464000"/> <!-- OnlyFurther necessary for Unix (root permissions required)Java options --> <entry key="withJocInstallAsDaemonjettyOptions" value="yes"/> </userInput> <!-- To enter a JOC User (default=current User). /com.izforge.izpack.panels.UserInputPanel> <com.izforge.izpack.panels.UserInputPanel id="joc"> <userInput> <!-- JOC can be installed in a cluster. Please type a unique title to identify the cluster node, For Unix only (root permissions required)!!!e.g. hostname. Max. length is 30 characters --> <entry key="runningUserjocTitle" value="jobschedulerPRIMARY JOC COCKPIT"/> <!-- PathChoose toyes Jettyif baseJOC directory is a standby node in a cluster --> <entry key="isStandby" value="no"/> For example: <!-- Security Level for the signing mechanism: possibly values are /home/[user]/sos-berlin.com/joc on Linux'LOW', 'MEDIUM' and 'HIGH' C:\ProgramData\sos-berlin.com\joc on Windows --> HIGH: <entry key="jettyBaseDir" value="/var/sos-berlin.com/js7/joc"/> public PGP keys are stored for verification only <!-- Choose (yes or no) wether the JOC's Jetty should be (re)started at the endall ofsigning thewill installation --> be done externally outside of JOC Cockpit <entry key="launchJetty" value="no"/> MEDIUM: <!-- Java options for Jetty. --> a <!-- Initial memory pool (-Xms) in MB -->private PGP key will be stored for signing <entry key="jettyOptionXms" value="128"/> signing will be done automatically with the <!-- Maximum memory pool (-Xmx) in MB --> provided key LOW: <entry key="jettyOptionXmx" value="512"/> <!-- Thread stack size (-Xss) inno KB --> keys will be stored <entry key="jettyOptionXss" value="4000"/> signing will be done <!-- Further Java optionsinternally with default keys --> <entry key="jettyOptionssecurityLevel" value="LOW"/> </userInput> </com.izforge.izpack.panels.UserInputPanel> <com.izforge.izpack.panels.UserInputPanel id="jocdatabase"> <userInput> <!-- Reporting Database Configuration -- JOC can be installed in a cluster. Please type a unique title to identify the cluster node, > <!-- Database connection settings can be specified with following entries such as e.g. hostname. Max. length is 30 characters --> databaseHost, databasePort, ... or <entry key="jocTitle" value="PRIMARY JOC COCKPIT"/> by a hibernate configuration file <!-- Choose yes if JOC isPosible avalues standbyare node in a cluster'withoutHibernateFile' (default) and 'withHibernateFile'. --> <entry key="isStandbydatabaseConfigurationMethod" value="nowithoutHibernateFile"/> <!-- Security Level forChoose the database signingmanagement mechanism:system. possiblySupported values are 'LOWmysql' for MySQL, 'MEDIUM' and 'HIGH' HIGH: 'oracle' for Oracle, 'mssql' for MS SQL Server, public'pgsql' PGP keys are stored for verification only for PostgreSQL. Only if databaseConfigurationMethod=withoutHibernateFile --> all signing will be done externally outside of JOC Cockpit <entry key="databaseDbms" value="mysql"/> <!-- Path to a hibernate configuration file if MEDIUM:databaseConfigurationMethod=withHibernateFile --> <entry key="hibernateConfFile" value=""/> a private PGP key will be stored for signing <!-- You can choose between 'on' or 'off' to create the database tables. signing will be done automatically with theIf providedyou key have modified the initial data of an already existing installation, LOW: then the modifications will be undone. Data added remains unchanged. no keys will be stored This entry should be only 'off', when you signing will be done internally with default keyssure, that all tables are already created. --> <entry key="securityLeveldatabaseCreateTables" value="LOWoff"/> </userInput> </com.izforge.izpack.panels.UserInputPanel> <com.izforge.izpack.panels.UserInputPanel id="database"> dbconnection"> <userInput> <!-- Database Configuration if databaseConfigurationMethod=withoutHibernateFile --> <!-- Enter the name or ip address of the database host <userInput> This entry <!-- Reporting Database Configuration --> can also be used to configure the URL(s) for Oracle RAC databases. <!-- Database connection settings can be specified with following entries suchFor asexample: <entry key="databaseHost" value="(DESCRIPTION=(ADDRESS_LIST=(LOAD_BALANCE=OFF)(FAILOVER=ON) databaseHost, databasePort, ... or by a hibernate configuration file (ADDRESS=(PROTOCOL=TCP)(HOST=tst-db1.myco.com)(PORT=1604)) Posible values are 'withoutHibernateFile' (default) and 'withHibernateFile'. --> (ADDRESS=(PROTOCOL=TCP)(HOST=tst-db2.myco.com)(PORT=1604))) <entry key="databaseConfigurationMethod" value="withoutHibernateFile"/> <!-- Choose the database management system. Supported values are 'mysql' for MySQL, (CONNECT_DATA=(SERVICE_NAME=mydb1.myco.com)(SERVER=DEDICATED)))"/> The "databaseSchema" and "databasePort" entries should then be left empty. --> <entry key="databaseHost" value=""/> 'oracle' for Oracle, 'mssql' for MS SQL Server, 'pgsql' for PostgreSQL. Only if databaseConfigurationMethod=withoutHibernateFile --> <!-- Enter the port number for the database instance. Default ports are for MySQL 3306, <entry key="databaseDbms" value="mysql"/> <!-- Path to a hibernate configuration file if databaseConfigurationMethod=withHibernateFile Oracle 1521, MS SQL Server 1433, postgreSQL 5432. --> <entry key="hibernateConfFiledatabasePort" value=""/> <!-- You can choose between 'on' or 'off' to create the database tables.Enter the schema --> <entry If you have modified the initial data of an already existing installation,key="databaseSchema" value=""/> then <!-- Enter the modifications will be undone. Data added remains unchanged.user name for database access --> <entry key="databaseUser" value=""/> This entry should be only 'off', when you sure, that all tables are already created. <!-- Enter the password for database access --> <entry key="databaseCreateTablesdatabasePassword" value="off"/> </userInput> </com.izforge.izpack.panels.UserInputPanel> <com.izforge.izpack.panels.UserInputPanel id="dbconnectionjdbc"> <userInput> <!-- Database Configuration if databaseConfigurationMethod=withoutHibernateFile --> <!-- You Entercan specify thean nameexternal orJDBC ipconnector addressthen ofset theinternalConnector database= host no For license reasons MySQL, MS SQL Server and Oracle ojdbc7 JDBC This entry can also be used to configure the URL(s) fordrivers Oracleare RACnot databasesprovided. For example: Alternatively you can use the mariadb JDBC Driver for MySQL and <entry key="databaseHost" value="(DESCRIPTION=(ADDRESS_LIST=(LOAD_BALANCE=OFF)(FAILOVER=ON) the jTDS JDBC Driver for MS SQL Server which is provided. (ADDRESS=(PROTOCOL=TCP)(HOST=tst-db1.myco.com)(PORT=1604)) An Oracle ojdbc6 JDBC driver is also (ADDRESS=(PROTOCOL=TCP)(HOST=tst-db2.myco.com)(PORT=1604))) provided. --> <!-- You can choose between 'yes' or 'no' for using the internal (CONNECT_DATA=(SERVICE_NAME=mydb1.myco.com)(SERVER=DEDICATED)))"/> JDBC connector The "databaseSchema" and "databasePort" entries should then be left empty. or not --> <entry key="databaseHostinternalConnector" value="yes"/> <!-- EnterSelect the port number for the database instance. Default ports are for MySQL 3306,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"/> 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=""/> <com.izforge.izpack.panels.FinishPanel id="finish"/> </AutomatedInstallation>
Line 19: The
entrypoint.sh
script is copied from the build directory to the image. Users can apply their own version of the entrypoint script. The entrypoint script used by SOS looks like this:
Download: entrypoint.shCode Block language bash title JOC Cockpit Entrypoint Script linenumbers true collapse true #!/bin/sh JETTY_BASE="/var/sos-berlin.com/js7/joc" startini_to_startd() { # convert once ${JETTY_BASE}/resources/joc/start.ini to ${JETTY_BASE}/resources/joc/start.d if [ -d "${JETTY_BASE}/start.d" ]; then if [ -f "${JETTY_BASE}/resources/joc/start.ini" ] && [ -d "${JETTY_BASE}/resources/joc/start.d" ]; then echo "convert start.ini to start.d ini files" for file in "${JETTY_BASE}"/resources/joc/start.d/*.ini; do <!-- Enter the password for database access --> module="$(basename "$file" | cut -d. -f1)" echo "processing module ${module}" <entry key="databasePassword" value=""/> while read -r line; </userInput>do </com.izforge.izpack.panels.UserInputPanel> <com.izforge.izpack.panels.UserInputPanel id="jdbc"> <userInput> modulevariablekeyprefix="$(echo "${line}" | cut -d. -f1,2)" if <!-- Database Configuration --> [ "${modulevariablekeyprefix}" = "jetty.${module}" ] || [ "${modulevariablekeyprefix}" = "jetty.${module}Context" ]; then <!-- You can specify an external JDBC connector then set internalConnector = no modulevariablekey="$(echo "${line}" | cut -d= -f1 | sed 's/\s*$//g')" echo "${line}" For license reasons MySQL, MS SQLsed Server and Oracle ojdbc7 JDBC -i "s;.*${modulevariablekey}\s*=.*;${line};g" "${file}" fi done drivers are not provided.< "${JETTY_BASE}/resources/joc/start.ini" done mv -f "${JETTY_BASE}/resources/joc/start.ini" "${JETTY_BASE}/resources/joc/start.in~" Alternatively you canfi use the mariadb JDBC Driver for MySQL and the jTDS JDBC Driver for MS SQL Server which is provided. fi } add_start_configuration() { # overwrite ini files in start.d if available from config folder if [ -d "${JETTY_BASE}/start.d" ]; then if [ -d "${JETTY_BASE}/resources/joc/start.d" ]; then for file in "${JETTY_BASE}"/resources/joc/start.d/*.ini; do Anecho Oracle ojdbc6 JDBC driver is also provided. --> "copy ${file} -> ${JETTY_BASE}/start.d/" cp -f "$file" "${JETTY_BASE}/start.d/" <!-- You can choose between 'yes' or 'no' for using the internal JDBC connector done fi fi } add_jdbc_and_license() { # if license folder not empty then copy js7-license.jar to Jetty's class path if [ -d "${JETTY_BASE}/resources/joc/license" ]; then if [ -f "${JETTY_BASE}/resources/joc/lib/js7-license.jar" ]; then orecho not --> "copy ${JETTY_BASE}/resources/joc/lib/js7-license.jar -> ${JETTY_BASE}/lib/ext/joc/" cp -f "${JETTY_BASE}/resources/joc/lib/js7-license.jar" "${JETTY_BASE}/lib/ext/joc/" <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"> fi fi # if JDBC driver added then copy to Jetty's class path and move exiting JDBC drivers back to avoid conflicts if [ -d "${JETTY_BASE}/resources/joc/lib" ]; then if [ -n "$(ls "${JETTY_BASE}"/resources/joc/lib/*.jar 2>/dev/null | grep -v "js7-license.jar")" ]; then for file in "${JETTY_BASE}"/lib/ext/joc/*.jar; do if <userInput/> </com.izforge.izpack.panels.UserInputPanel>[ "$(basename "$file")" != "js7-license.jar" ]; then <com.izforge.izpack.panels.InstallPanel id="install"/> <com.izforge.izpack.panels.ProcessPanel id="process"/> <com.izforge.izpack.panels.FinishPanel id="finish"/> </AutomatedInstallation>
Line 19: The
entrypoint.sh
script is copied from the build directory to the image. Users can apply their own version of the entrypoint script. The entrypoint script used by SOS looks like this:
Download: entrypoint.shCode Block language bash title JOC Cockpit Entrypoint Script linenumbers true collapse true #!/bin/sh JETTY_BASE="/var/sos-berlin.com/js7/joc" add_jdbc_and_license() { # if license folder not empty then copy js7-license.jar to Jetty's class path if [ -d "echo "move ${file} -> ${JETTY_BASE}/resources/joc/lib/$(basename "$file")~" mv -f "$file" "${JETTY_BASE}/resources/joc/lib/$(basename "$file")~" fi done for file in "${JETTY_BASE}"/resources/joc/lib/*.jar; do echo "copy ${file} -> ${JETTY_BASE}/resourceslib/ext/joc/license" ]; then if [ !cp -zf "$file"`ls -A "${JETTY_BASE}/lib/resourcesext/joc/license/`" ]; then" done fi fi } patch_jars() { if [ -fd "${JETTY_BASE}/resources/joc/lib/js7-license.jarpatches" ]; then echo "extract patch files echoif exist"copy ${JETTY_BASE}/resources/joc/lib/js7-license.jar -> ls "${JETTY_BASE}/lib/ext/joc/""/resources/joc/patches/*.jar 2>/dev/null if [ -n cp -f "$(ls "${JETTY_BASE}"/resources/joc/libpatches/js7-license*.jar ${JETTY_BASE}/lib/ext/joc/ fi2>/dev/null)" ]; then fi fi if [ # if JDBC driver added then copy to Jetty's class path and move exiting JDBC drivers back to avoid conflicts if [ -d-d "${JETTY_BASE}/webapps/joc/WEB-INF/classes" ]; then CUR_DIR="$(pwd)" cd "${JETTY_BASE}/resourceswebapps/joc/libWEB-INF/classes" ]; then if [ !for -zfile `lsin "${JETTY_BASE}"/resources/joc/libpatches/*.jar; |do grep -v "js7-license.jar"` ]; then echo for"extract ${file} in-> ${JETTY_BASE}/libwebapps/extjoc/joc/*.jar; doWEB-INF/classes" if [ "`basename $file`" != "js7-license.jar" ]; then unzip -o "${file}" done echo "move ${file} -> cd "${JETTYCUR_BASE}/resources/joc/lib/`basename $file`~DIR}" fi mv -f $file ${JETTY_BASE}/resources/joc/lib/`basename $file`~ fi done for file in ${JETTY_BASE}/resources/joc/lib/*.jar; do echo "copy ${file} -> ${JETTY_BASE}/lib/ext/joc/" cp -f $file fi fi } # create Jetty start script echo "#!/bin/sh" > /usr/local/bin/start-joc.sh echo "/opt/sos-berlin.com/js7/joc/jetty/bin/jetty.sh start && tail -f /dev/null" >> /usr/local/bin/start-joc.sh chmod +x /usr/local/bin/start-joc.sh startini_to_startd add_start_configuration if [ ! "$RUN_JS_HTTP_PORT" = "" ] then if [ -f "${JETTY_BASE}/lib/ext/joc/ done fi fi } patch_jars() { if [ -dstart.d/http.in~" ] && [ ! -f "${JETTY_BASE}/resources/joc/patchesstart.d/http.ini" ]; then # echoenable "extracthttp patchaccess filesin if exist"start.d directory lsmv "${JETTY_BASE}/resources/joc/patches/*.jar 2>/dev/null start.d/http.in~" "${JETTY_BASE}/start.d/http.ini" fi if [ ! -zf "`ls ${JETTY_BASE}/resources/joc/patches/*.jar`start.d/http.ini" ]; then # set port iffor [http -d "${JETTY_BASE}/webapps/joc/WEB-INF/classes" ]; thenaccess in start.d directory sed CUR_DIR="`pwd`" cd -i "s/.*jetty.http.port\s*=.*/jetty.http.port=$RUN_JS_HTTP_PORT/g" "${JETTY_BASE}/webapps/joc/WEB-INF/classesstart.d/http.ini" fi else if [ for file in -f "${JETTY_BASE}/resources/joc/patches/*.jar; dostart.d/http.ini" ]; then # disable http access in echo "extract ${file} -> start.d directory mv -f "${JETTY_BASE}/webapps/joc/WEB-INF/classes" unzip -o ${file} done cd "${CUR_DIR}" fi fi fi } # create Jetty start script echo "#!/bin/sh" > /usr/local/bin/start-joc.sh echo "/opt/sos-berlin.com/js7/joc/jetty/bin/jetty.sh start && tail -f /dev/null" >> /usr/local/bin/start-joc.sh chmod +x /usr/local/bin/start-joc.sh if [ ! "$RUN_JS_HTTP_PORT" = "" ] then # enable http access sed -i "s/.*--module=http$/--module=http/g" ${JETTY_BASE}/start.ini start.d/http.ini" "${JETTY_BASE}/start.d/http.in~" fi fi if [ ! "$RUN_JS_HTTPS_PORT" = "" ] then if [ -f "${JETTY_BASE}/start.d/https.in~" ] && [ ! -f "${JETTY_BASE}/start.d/https.ini" ]; then # enable https access in start.d directory mv "${JETTY_BASE}/start.d/https.in~" "${JETTY_BASE}/start.d/https.ini" fi if [ -f "${JETTY_BASE}/start.d/ssl.in~" ] && [ ! -f "${JETTY_BASE}/start.d/ssl.ini" ]; then # enable https access in start.d directory mv "${JETTY_BASE}/start.d/ssl.in~" "${JETTY_BASE}/start.d/ssl.ini" fi if [ -f "${JETTY_BASE}/start.d/ssl.ini" ]; then # set port for httphttps access in start.d directory sed -i "s/.*jetty.httpssl.port\s*=.*/jetty.httpssl.port=$RUN_JS_HTTPHTTPS_PORT/g" "${JETTY_BASE}/start.ini elsed/ssl.ini" # disable http accessfi else sedif -i "s/\s*--module=http$/# --module=http/g" [ -f "${JETTY_BASE}/start.ini fi if [ ! "$RUN_JS_HTTPS_PORT" = "" ] then d/https.ini" ]; then # enabledisable https access in start.d directory sedmv -if "s/.*--module=https$/--module=https/g" ${JETTY_BASE}/start.d/https.ini" "${JETTY_BASE}/start.inid/https.in~" #fi set port for https access sedif [ -i "s/\s*jetty.ssl.port\s*=.*/jetty.ssl.port=$RUN_JS_HTTPS_PORT/g" f "${JETTY_BASE}/start.d/ssl.ini else " ]; then # disable https access in start.d directory sed mv -if "s/\s*--module=https$/# --module=https/g" ${JETTY_BASE}/start.d/ssl.ini" "${JETTY_BASE}/start.ini.d/ssl.in~" fi fi if [ ! -zn "$RUN_JS_JAVA_OPTIONS" ] then export JAVA_OPTIONS="${JAVA_OPTIONS} $RUN_JS_JAVA_OPTIONS" fi JS_USER_ID=`echo$(echo "$RUN_JS_USER_ID" | cut -d ':' -f 1`1) JS_GROUP_ID=`echo$(echo "$RUN_JS_USER_ID" | cut -d ':' -f 2`2) BUILD_GROUP_ID=`cat$(cat /etc/group | grep jobscheduler | cut -d ':' -f 3`3) BUILD_USER_ID=`cat$(cat /etc/passwd | grep jobscheduler | cut -d ':' -f 4`4) add_jdbc_and_license patch_jars if [ "$(id -u)" = "0" ] then if [ ! "$BUILD_USER_ID" = "$JS_USER_ID" ] then echo "JS7 entrypoint script switching ownership of image user id '$BUILD_USER_ID' -> '$JS_USER_ID', group id '$BUILD_GROUP_ID' -> '$JS_GROUP_ID'" usermod -u "$JS_USER_ID" jobscheduler groupmod -g "$JS_GROUP_ID" jobscheduler find /var/sos-berlin.com/ -group "$BUILD_GROUP_ID" -exec chgrp -h jobscheduler {} \; find /var/sos-berlin.com/ -user "$BUILD_USER_ID" -exec chown -h jobscheduler {} \; find /var/log/sos-berlin.com/ -group "$BUILD_GROUP_ID" -exec chgrp -h jobscheduler {} \; find /var/log/sos-berlin.com/ -user "$BUILD_USER_ID" -exec chown -h jobscheduler {} \; fi echo "JS7 entrypoint script switching to user account 'jobscheduler' to run start script" echo "JS7 entrypoint script starting JOC Cockpit: exec su-exec jobscheduler:$JS_GROUP_ID /opt/sos-berlin.com/js7/joc/jetty/bin/jetty.sh start" exec su-exec jobscheduler:"$JS_GROUP_ID" /usr/local/bin/start-joc.sh else if [ "$BUILD_USER_ID" = "$JS_USER_ID" ] then if [ "$(id -u)" = "$JS_USER_ID" ] then echo "JS7 entrypoint script running for user id '$(id -u)'" else echo "JS7 entrypoint script running for user id '$(id -u)' cannot switch to user id '$JS_USER_ID', group id '$JS_GROUP_ID'" echo "JS7 entrypoint script missing permission to switch user id and group id, consider to omit the 'docker run --user' option" fi else echo "JS7 entrypoint script running for user id '$(id -u)' cannot switch image user id '$BUILD_USER_ID' -> '$JS_USER_ID', group id '$BUILD_GROUP_ID' -> '$JS_GROUP_ID'" echo "JS7 entrypoint script missing permission to switch user id and group id, consider to omit the 'docker run --user' option" fi echo "JS7 entrypoint script starting JOC Cockpit: exec sh -c /opt/sos-berlin.com/js7/joc/jetty/bin/jetty.sh start" exec sh -c "/usr/local/bin/start-joc.sh" fi
- Note that the entrypoint script runs the JOC Cockpit start script using
exec sh -c
. This is required to run the JOC Cockpit inside the current process that is assigned PID 1. A laterdocker kill <container>
command will send a SIGKILL signal to the process with PID 1 only. If JOC Cockpit were started directly as a shell script without use ofexec
then a new process with a different PID would be created. This means that thedocker kill
command would not be successful and, for example, would not cause a fail-over between clustered JOC Cockpit containers.
- Note that the entrypoint script runs the JOC Cockpit start script using
- Line 22: The
config
folder available in the build directory is copied to the appropriateconfig
folder in the image. This can be useful for creating an image with individual settings in configuration files, see the JS7 - JOC Cockpit Configuration Items article for more information.- The
hibernate.cfg.xml
specifies the database connection. This file is not used at build-time. However, it is provided as a sample for run-time configuration. You will find details in the JS7 - Database article. - The default
https-keystore.p12
andhttps-truststore.p12
files are copied that would hold the private key and certificate required for server authentication with HTTPS. By default empty keystore and truststore files are used that users would add their private keys and certificates to at run-time.
- The
- Line 35 - 38: 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 41 - 44: 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 55 - 61: The image OS is updated and additional packages are installed (ps, netstat, bash).
- Line 62: The most recent Java 11 package available with Alpine is applied. JOC Cockpit can be operated with newer Java releases. However, stick to Oracle, OpenJDK or AdoptOpenJDK as the source for your Java LTS release. Alternatively you can use your own base image and install Java 1.8 or later on top of this. For details see Which Java versions is JobScheduler available for?
- Line 63 - 64: Java releases might make use of
/dev/random
for random number generation. This is a bottleneck as random number generation with this file is blocking. Instead/dev/urandom
should be used that implements non-blocking behavior. The change of the random file is applied to the Java security file. - Line 65: The
jobscheduler
user account is created and assigned the user id and group id handed over by the relevant 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 67 - 70: The JOC Cockpit setup is performed.
- Line 74 - 75: The keystore and truststore locations are added to the Jetty
start.d/ssl.ini
file andjoc.properties
file respectively.start.d/ssl.ini.add
is used for access e.g. by client browsers:Code Block language bash title Jetty HTTPS Configuration File start.d/ssl.ini.add linenumbers true collapse true ## 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 if such connections require HTTPS mutual authentication:Code Block language bash title JOC Cockpit configuration File joc.properties.add linenumbers true collapse true ################################################################################ ### 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 77: The Jetty servlet container is added the HTTPS module for use with the JOC Cockpit.
- Line 106 - 108: The entrypoint script and start script are executed and dynamically parameterized from environment variables which are forwarded when starting the container.
...
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
#!/bin/sh set -e SCRIPT_HOME=$(dirname "$0") SCRIPT_HOME="`cd "${SCRIPT_HOME}" >/dev/null && pwd`" SCRIPT_FOLDER="`basename $(dirname "$SCRIPT_HOME")`" # ----- modify default settings ----- JS_RELEASE="2.15.0" JS_REPOSITORY="sosberlin/js7" JS_IMAGE="$(basename "${SCRIPT_HOME}")-${JS_RELEASE//\./-}" JS_USER_ID="$UID" JS_HTTP_PORT="4446" JS_HTTPS_PORT= 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=//'` ;; --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 \ --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 |
...