JS7® JobScheduler docker-compose で起動


概要

JS7 jobscheduler を手っ取り早く触りたい人向け
docker-composeでの実行方法

準備

必要なファイル、ディレクトリを準備します。

docker-compose.yml

version: '3'


services:

  db:
    image: mysql:8.0
    command: --default-authentication-plugin=mysql_native_password
    volumes: 
      - db_data:/var/lib/mysql
    networks:
      - js7network
    environment:
      MYSQL_ROOT_PASSWORD: iLoveMySQL8.0!
      MYSQL_DATABASE: js7db
      MYSQL_USER: js7user
      MYSQL_PASSWORD: js7password
    restart: "no"

  js7-joc-primary:
    depends_on:
      - db
    image: sosberlin/js7:joc-${JS7VERSION}
    hostname: js7-joc-primary
    ports:
      - "4446:4446"
    volumes:
      - js7-joc-primary-config:/var/sos-berlin.com/js7/joc/resources/joc
      - js7-joc-primary-logs:/var/log/sos-berlin.com/js7/joc
    networks:
      - js7network
    environment:
      RUN_JS_JAVA_OPTIONS: -Xmx256m
      RUN_JS_USER_ID: "${JS7USERID}:${JS7GROUPID}"
    restart: "no"

  js7-controller-primary:
    image: sosberlin/js7:controller-${JS7VERSION}
    hostname: js7-controller-primary
    volumes:
      - js7-controller-primary:/var/sos-berlin.com/js7/controller/var
    networks:
      - js7network
    environment:
      RUN_JS_JAVA_OPTIONS: -Xmx256m
      RUN_JS_USER_ID: "${JS7USERID}:${JS7GROUPID}"
    restart: "no"

  js7-agent-primary:
    image: sosberlin/js7:agent-${JS7VERSION}
    hostname: js7-agent-primary
    volumes:
      - js7-agent-primary:/var/sos-berlin.com/js7/agent/var_4445
    networks:
      - js7network
    environment:
      RUN_JS_JAVA_OPTIONS: -Xmx256m
      RUN_JS_USER_ID: "${JS7USERID}:${JS7GROUPID}"
    restart: "no"


volumes:

  db_data:
    driver: local
    driver_opts:
      type: none
      device: ${PWD}/db_data
      o: bind

  js7-joc-primary-config:
    driver: local
    driver_opts:
      type: none
      device: ${PWD}/js7-joc-primary-config
      o: bind

  js7-joc-primary-logs:
    driver: local
    driver_opts:
      type: none
      device: ${PWD}/js7-joc-primary-logs
      o: bind

  js7-controller-primary:
    driver: local
    driver_opts:
      type: none
      device: ${PWD}/js7-controller-primary
      o: bind

  js7-agent-primary:
    driver: local
    driver_opts:
      type: none
      device: ${PWD}/js7-agent-primary
      o: bind


networks:
  js7network:

hibernate.cfg.xml

<?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">js7password</property>
  <property name="hibernate.connection.url">jdbc:mariadb://db:3306/js7db</property>
  <property name="hibernate.connection.username">js7user</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>
  <property name="hibernate.connection.provider_class">org.hibernate.hikaricp.internal.HikariCPConnectionProvider</property>
  <property name="hibernate.hikari.maximumPoolSize">10</property>
 </session-factory>
</hibernate-configuration>

.env (環境変数用) ※バージョンは任意

echo -e "JS7USERID=$(id -u)\nJS7GROUPID=$(id -g)\nJS7VERSION=2-2-3" > .env

# 確認
cat .env
JS7USERID=1000
JS7GROUPID=1000
JS7VERSION=2-2-3

ディレクトリ

mkdir db_data
mkdir js7-agent-primary
mkdir js7-controller-primary
mkdir js7-joc-primary-config
mkdir js7-joc-primary-logs

ここまでで、下記のような構成になります。

.
├── .env
├── db_data
├── docker-compose.yml
├── hibernate.cfg.xml
├── js7-agent-primary
├── js7-controller-primary
├── js7-joc-primary-config
└── js7-joc-primary-logs

コンテナ起動

まずコンテナを起動

$ docker-compose up -d

# 確認
$ docker-compose ps
NAME                            COMMAND                  SERVICE                  STATUS              PORTS
js74-db-1                       "docker-entrypoint.s…"   db                       running             33060/tcp
js74-js7-agent-primary-1        "sh /usr/local/bin/e…"   js7-agent-primary        running             
js74-js7-controller-primary-1   "sh /usr/local/bin/e…"   js7-controller-primary   running             
js74-js7-joc-primary-1          "sh /usr/local/bin/e…"   js7-joc-primary          running             0.0.0.0:4446->4446/tcp, :::4446->4446/tcp

hibernate.cfg.xmlをVolumeマウント先に上書きコピー (インストール時に使用します)

cp -f hibernate.cfg.xml js7-joc-primary-config/

js7-joc-primary にて 上記ファイルを指定してインストール

docker-compose exec js7-joc-primary /bin/sh -c /opt/sos-berlin.com/js7/joc/install/joc_install_tables.sh

# ログ確認
tail js7-joc-primary-logs/install-result.log

# js7-joc-primary のみ再起動
docker-compose restart js7-joc-primary

動作チェック

あとは、ブラウザで js7-joc-primary にて指定したポート番号にアクセスしてください。
http://localhost:4446/

※初期ユーザーは Account: root / password: root です