0
0

nablarch: nablarch-example-restをdockerコンテナにする方法

Posted at

はじめに:nablarch-example-restの課題

nablarch-example-restは、nablarchフレームワークのRESTアプリケーション実装例である。

ただし、nablarch-example-restはdocker用のexampleを提供していない。
かわりにwaitt(Web Application Integration Test Tool)ツールによるexampleが提供されているが、
waittは複数アプリの結合などを行うことが難しい上にメンテナンスされていないため、tomcatバージョンも変更困難である点が難点。

このページでは、より人気が高く機能も豊富であるdockerコンテナでnablarch-example-restを動かす方法を説明する。

前提条件

  • docker(インストール手順はこちらを参照)
  • jdk(8または17)
  • maven(ただし、maven wrapperがある場合は不要)

アクセス例

target\nablarch-example-rest-5u24.war は、手順に従って事前生成されている前提とする。
手順はhttps://github.com/nablarch/nablarch-example-restを参照。

compose.yml
services:
  backend:
      build: .
      tty: true
      ports:
        - 8080:8080
Dockerfile
# syntax=docker.io/docker/dockerfile:1
FROM tomcat:9.0-jre8-temurin

# h2の仕様では、相対パスのみが使用される場合現在の作業ディレクトリが開始点として使用されます。
# tomcatコンテナイメージでは、デフォルトの作業ディレクトリは/usr/local/tomcatです。
# env.properties で nablarch.db.url=jdbc:h2:./h2/db/rest_example を設定する場合、/usr/local/tomcat/h2/db/が正しい配置場所です。
COPY ./h2/db/rest_example.mv.db /usr/local/tomcat/h2/db/
# /usr/local/tomcat/webapps/配下に、任意の名前でwarを配置する。この名前が後でアクセスする際のURLパスとなる。
COPY ./target/nablarch-example-rest-5u24.war /usr/local/tomcat/webapps/nablarch-example-rest.war

docker composeコマンドの実行

docker compose up -d

アクセス例は以下

上手くいけば、以下のように表示される。

image.png

オプション:tomcat管理画面を利用したい場合

このDockerfileの場合、tomcat管理画面が利用できない。
tomcat管理画面を利用したい場合は別記事を用意しているので、そちらを参照。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0