feat: crane_web_debugger の Docker 開発時ホットリロードを有効化#1342
Merged
Conversation
## 背景 ソースを編集するたびに `docker compose build` が必要で開発効率が悪かった。 フロントエンドは素の HTML/JS で、Python サーバも静的配信のみという構成のため、 ボリュームマウントと uvicorn --reload で容易に解決できる。 ## 変更内容 - `docker/dev/docker-compose.yaml`: `web-debugger` サービスに volumes と command を追加 - `crane_web_debugger/web/` と `web_server/app.py` をコンテナへ read-only マウント - uvicorn を `--reload --reload-include app.py` オプションで起動 - `WEB_ROOT` 環境変数を追加 - `crane_web_debugger/web_server/app.py`: - モジュールトップレベルで `app` を生成し、uvicorn の import-string 形式に対応 - `WEB_ROOT` 環境変数でルートディレクトリを指定可能に(デフォルト: `/app/web`) - 従来の `python3 app.py --web-root ...` 起動との後方互換を維持
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.
概要
crane_web_debuggerの開発ワークフロー改善。ソース変更のたびにdocker compose buildが必要だった問題を解消し、ブラウザリロードまたは uvicorn 自動再起動で変更を反映できるようにする。背景・根本原因
docker/dev/docker-compose.yamlのweb-debuggerサービスにvolumes設定がなく、web/とweb_server/app.pyが Dockerfile のCOPYによってイメージへ焼き込まれていた。そのため、フロントエンドの微小な変更でも再ビルドが必須となっていた。変更内容
docker/dev/docker-compose.yamlcrane_web_debugger/web/→/app/webに read-only マウントを追加crane_web_debugger/web_server/app.py→/app/app.pyに read-only マウントを追加--reload --reload-include app.py付きで起動するようcommandを上書き(静的ファイル変更では不要なリロードが走らないようreload-includeで絞り込み)WEB_ROOT環境変数を追加crane_web_debugger/web_server/app.pyapp = create_app(...)を生成し、uvicorn の"app:app"import-string 形式(--reloadに必要)に対応WEB_ROOT環境変数でルートディレクトリを指定可能に(デフォルト:/app/web)python3 app.py --web-root ...起動との後方互換を維持(Dockerfile のCMDは変更なし)開発フローの変化
web/*.html/.js/.css編集docker compose build+up -dweb_server/app.py編集docker compose build+up -drequirements.txt更新docker compose build+up -d