Skip to content

docker-compose.yml: サービスおよびインフラのヘルスチェック設定が欠落している #16

@devin-ai-integration

Description

@devin-ai-integration

概要

docker-compose.yml において、PostgreSQL・RabbitMQ のヘルスチェック定義と、各サービスの depends_on における condition: service_healthy が設定されていません。これにより、docker compose up 実行時にインフラコンテナ(DB、メッセージブローカー)が準備完了する前にアプリケーションサービスが起動し、接続エラーが発生する可能性があります。

現状

  • 各サービスの Program.cs では /healthz エンドポイントが実装済み
  • しかし docker-compose.ymldepends_on は単純なサービス名指定のみで、ヘルスチェック条件がない
  • postgresrabbitmq サービスにも healthcheck ブロックが定義されていない

再現手順

  1. docker compose up --build を実行
  2. PostgreSQL の初期化が完了する前にサービスが起動し、DB接続エラーが発生する場合がある

期待される修正

1. インフラサービスにヘルスチェックを追加

postgres:
  image: postgres:16-alpine
  healthcheck:
    test: ["CMD-SHELL", "pg_isready -U postgres"]
    interval: 5s
    timeout: 5s
    retries: 5

rabbitmq:
  image: rabbitmq:3-management-alpine
  healthcheck:
    test: ["CMD", "rabbitmq-diagnostics", "-q", "ping"]
    interval: 10s
    timeout: 5s
    retries: 5

2. 各アプリケーションサービスの depends_on に条件を追加

depends_on:
  postgres:
    condition: service_healthy
  rabbitmq:
    condition: service_healthy

3. (任意) 各アプリケーションサービスにもヘルスチェックを追加

healthcheck:
  test: ["CMD", "curl", "-f", "http://localhost:<port>/healthz"]
  interval: 10s
  timeout: 5s
  retries: 3

対象ファイル

  • src/docker-compose.yml

補足

docker-compose.ymlversion: '3.8' キーも Docker Compose V2 では非推奨のため、合わせて削除を検討してください。

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions