Repository navigation
実行イメージを distroless の Java 17 にする - #14
Merged
Merged
Conversation
- 実行段を tomcat:9.0-jre17-temurin から gcr.io/distroless/java17-debian13 に。シェルも apt も無い。 Tomcat は公式イメージで組み立てた $CATALINA_HOME をまるごと写す (APR・*.sh・webapps.dist は外す) - docker-entrypoint.sh (sh + awk) を launcher/MospLauncher.java に置き換え。DB接続設定の反映を 同じ規則で行ってから、同じ JVM で Bootstrap start を呼ぶ。catalina.sh run が組んでいた java のコマンドライン (JDK_JAVA_OPTIONS の --add-opens を含む) を exec の形で書いた - chart の initContainer copy-sql は sh -c 'cp -a …' をやめ、イメージの入口の copy を使う (args: [copy, SRC, DST])。イメージと揃えて上げる必要があるので chart を 0.4.0 に - ユーザは今までどおり root。LANG は C.UTF-8 (file.encoding / sun.jnu.encoding は UTF-8 のまま) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QTh6wTyvpp9FAHK1pPe2Rm
|
Claude finished @5ym's task in 24s —— View job レビュー結果実装を 確認できた点:
要確認 / 軽微な指摘(いずれも任意)
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
なぜ
実行イメージにシェルやパッケージマネージャを置かず、攻撃面を減らすため (danything の他のアプリと同じ方針)。
変えたこと
tomcat:9.0-jre17-temurin→gcr.io/distroless/java17-debian13(Temurin 17 の JRE)。Tomcat は今までどおり公式イメージで組み立てた$CATALINA_HOMEをまるごと写す。使わないもの (bin/*.sh、Tomcat Native (APR) のnative-jni-lib、webapps.dist) は外したdocker-entrypoint.sh(sh + awk) →launcher/MospLauncher.java。DB接続設定 (connection.xml/setup.xml) を同じ規則で書き換えてから、同じ JVM でorg.apache.catalina.startup.Bootstrap startを呼ぶ。catalina.sh runが組んでいた java のコマンドライン (JDK_JAVA_OPTIONSの--add-opens、-Dcatalina.*、juli のロギングなど) は動いているコンテナの/proc/1/cmdlineと environ から写し、exec の形のENTRYPOINTに書いた。SIGTERM で Tomcat はふつうに止まるcopy-sqlのsh -c 'cp -a …'を、イメージの入口の copy (args: [copy, /usr/local/tomcat/webapps/ROOT/sql, /mosp-sql]) に。db-bootstrapは postgres のイメージなのでそのまま。probe はもともと無いWEB-INF/xmlを書き換え、ログの PVC に書くため)。文字コードはLANG=C.UTF-8(distroless の既定) で、file.encoding/sun.jnu.encodingは UTF-8 のまま。TZは今までどおり chart から渡すhttp-nio-8080。TLS は Ingress で終端)。起動ログに「Tomcat Native library … was not found」の INFO が 1 行出るだけpathsと README をlauncher/**に合わせた確かめたこと (手元で build して run)
copyで SQL を写す (中身は元のイメージと同じ 5 ファイル) → chart のdb-bootstrapのスクリプトをそのまま流す (bootstrap done) → MosP を起動connection.xml/setup.xmlを比べた。バイト単位で同じだった (jdbc:postgresql://host:port/db?…、\ $ / | "を含むパスワード、MOSP_DB_DRIVERも試した)?var=のタイムスタンプ以外)。新しい版でユーザを登録して「新規登録しました。」→ DB に山田|太郎|ヤマダが入り、以後はログイン画面に戻る。ログの PVC にmosp0.logが書かれる。SEVERE も例外も無しstopで Tomcat がふつうに止まる (Stopping ProtocolHandler)気をつけること
copy-sqlはshを呼ぶので新しいイメージでは起動しない。新しい chart (0.4.0) のargs: [copy …]は古いイメージでは動かない。image.tagの既定はlatestなので、このPRをマージするとイメージ (build-and-push) と chart (publish-chart) が両方作り直される。使っている側は chart を 0.4.0 に上げてから Pod を作り直すkubectl debugで横にコンテナを付ける🤖 Generated with Claude Code
https://claude.ai/code/session_01QTh6wTyvpp9FAHK1pPe2Rm