5月25日の続き。
Docker Hubにある公式イメージ(本日時点でWildflyはバージョン10)をカスタマイズできないか試しています。
もっといいやり方があると思いますが、一旦メモ。
Ubuntu 16.04でやっています。
コードの汚さはとりあえず気にしない。
(1)設定用シェル
$ vi preparation.sh
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/bin/sh
# Install Middleware
yum -y update
yum -y install iproute ntp ntpdate
# Install JDBC Driver (PostgreSQL)
yum -y install postgresql-jdbc.noarch
# Configuration Wildfly (Profile:testdir)
cp -pfr /opt/jboss/wildfly/standalone /opt/jboss/wildfly/testdir
# Wildfly Boot
/opt/jboss/wildfly/bin/standalone.sh -b=0.0.0.0 -bmanagement=0.0.0.0 -Djboss.server.base.dir=/opt/jboss/wildfly/testdir &
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
$ vi config.sh
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#!/bin/sh
# Delete X-Powered-By Header
/opt/jboss/wildfly/bin/jboss-cli.sh --connect --commands="cd /subsystem=undertow/server=default-server/host=default-host/filter-ref=x-powered-by-header,:remove"
# Delete Server Header
/opt/jboss/wildfly/bin/jboss-cli.sh --connect --commands="cd /subsystem=undertow/server=default-server/host=default-host/filter-ref=server-header,:remove"
# ADD AJP
/opt/jboss/wildfly/bin/jboss-cli.sh --connect --command="/subsystem=undertow/server=default-server/ajp-listener=ajp:add(socket-binding=ajp,scheme=http,enabled=true)"
# Instance ID
/opt/jboss/wildfly/bin/jboss-cli.sh --connect --commands="cd /subsystem=undertow, :write-attribute(name=instance-id,value=node1), :read-resource"
# Deloploy Application
/opt/jboss/wildfly/bin/jboss-cli.sh --connect --commands="deploy /usr/share/java/postgresql-jdbc.jar"
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
(2)Dockerイメージおよびコンテナの作成
$ sudo docker pull docker.io/jboss/wildfly:latest
$ vi Dockerfile
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
FROM docker.io/jboss/wildfly:latest
# Add Middleware
ADD preparation.sh /opt/jboss
ADD config.sh /opt/jboss
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
$ sudo docker build -t wildfly .
$ sudo docker run --privileged -u=root -d -p 8080:8080 --name wildfly wildfly /sbin/init
$ sudo docker exec -it wildfly /bin/bash
(3)Wildfly設定(コンテナ上の操作)
# pwd
/opt/jboss
# chmod +x /opt/jboss/preparation.sh
# chmod +x /opt/jboss/config.sh
# ./preparation.sh
# ./config.sh
設定が終わったら、Wildflyを再起動してブラウザから
http://localhost:8080/
を確認する。
ブラウザの開発者ツールでヘッダを見ると、隠蔽されていることを確認できる。