無駄実装の削除とパフォーマンス改善(waste audit 第2弾)#29
Conversation
Waste removal: - Delete orphaned duplicate Django project tree (app/) - Delete broken/unused files: "import os.py", index.html, articles.js, duplicate test-data scripts, unbuildable Dockerfile, Dockerfile.nginx.static, nginx/Dockerfile, orphaned root nginx.conf, redundant compose static service - Remove 6 unused dependencies (whitenoise, compressor, cors-headers, csp, sentry-sdk, django-extensions) - Remove broken Django admin routing entirely (/admin/ now always 404) - Merge never-loaded settings_production.py into settings.py Performance: - Add CONN_MAX_AGE=60 (was reconnecting to PostgreSQL every request) - Fix N+1 queries with select_related/annotate (article list: 2 queries flat) - Paginate article/category/tag list views (10 per page) - Cache rendered article Markdown in Redis keyed by updated_at; disable Pygments guess_lang - Cache sidebar categories/tags via context processor with signal invalidation - Enable nginx gzip, turn proxy_buffering on - Production gunicorn config (no reload, info log, fixed workers) - Add missing migrations (initial + composite index on published/created_at) and use migrate --fake-initial in entrypoint - Resize uploaded images to 1920px max with EXIF orientation fix - Use cached template loader when DEBUG=False Operational fixes found during E2E verification: - Dockerfile.nginx copied a static/ dir deleted in 266aeab (build was broken) - Exempt /health/ and /ready/ from SSL redirect so container healthcheck passes with DEBUG=False - Inject REDIS_PASSWORD into CACHES so caching/sessions work against password-protected Redis Implementation by Codex CLI under Claude orchestration. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…y scan on PRs The build job relied on the repo-root Dockerfile, which was removed in this PR (it had no FROM instruction and could never build). Build the real app image from Dockerfile.django instead. Load the image into the local Docker store on pull_request events (where push is disabled) and scan a single sha-tagged reference so the Trivy step has a valid target. Bump checkout and setup-python to current majors to clear Node 20 deprecation warnings. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Resolves the 22 CRITICAL/HIGH vulnerabilities Trivy found in the image: Django 4.2.30 (CVE-2024-42005 SQL injection and later LTS fixes), gunicorn 23 (CVE-2024-1135), Pillow >=12.1.1 (CVE-2026-25990), and upgraded pip/setuptools/wheel in the image (wheel CVE-2026-24049, jaraco.context CVE-2026-23949). black/flake8/isort are unused in this repo (per the waste audit) and black 23.12 carried CVE-2026-32274, so they are removed from the image entirely. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
@claude この PR の CI 結果(test / build / Trivy スキャン)を確認して、直近 3 コミットで何が修正されたかを日本語で簡潔に要約してください。 |
|
Claude finished @dendencat's task in 37s —— View job CI 結果と直近3コミットの要約
CI 結果(最新実行: run 29648820817)
2 ワークフローとも成功、失敗ステップなし。Trivy スキャンは 直近3コミットの内容
まとめ: |
概要
CMS 全体を「無駄な実装」「処理速度を落としている実装」の観点で監査し(#27/#28 の waste audit の続き)、検出した問題をすべて修正しました。実装は Codex CLI、指揮・レビューは Claude が担当。-754 行 / +450 行。
無駄の削除
app/ツリーを削除(どの Docker 構成からも未参照)techblog_cms/import os.py(不正なファイル名の死んだテスト)、未使用のindex.html・static/js/articles.js、重複テストデータスクリプト 2 本HIDE_ADMIN_URLハードコードで到達不能、フラグ切替時は無限リダイレクト)。/admin/は常に 404Dockerfile、Dockerfile.nginx.static、nginx/Dockerfile、孤立nginx.conf、nginx と二重配信だった composestaticサービスsettings_production.pyを base に統合して削除パフォーマンス改善
CONN_MAX_AGE=60(従来は毎リクエスト再接続)select_related('category')/annotate(Count)。記事 15 件で /articles/ が 2 クエリ(実測)updated_atキーで自動無効化)、Pygmentsguess_lang無効化proxy_buffering on(sync worker の占有解消)reload=False・loglevel=info・worker 数を環境変数化(published, -created_at)複合インデックス追加--fake-initial化E2E 検証で発見した既存バグの修正
Dockerfile.nginxが 266aeab で削除済みのstatic/を COPY していてビルド不能 → 冗長 COPY を削除DEBUG=False時に SSL リダイレクトがコンテナ内部 healthcheck まで HTTPS に飛ばし恒常的に unhealthy →SECURE_REDIRECT_EXEMPTを追加--requirepass起動なのに CACHES に認証情報が渡らずキャッシュ・セッションが無効化 →REDIS_PASSWORDを CACHES に注入検証
pytest: 23 passed(ページネーション・画像リサイズ・キャッシュのテストを追加)/admin/404、Redis 上にキャッシュキー生成を確認.envのDATABASE_URLをPOSTGRES_*と整合する値に要修正(詳細はレビューコメント参照)🤖 Generated with Claude Code