From b66fd5fb0afc6413d01ba1f629cdd4e89b0d8f5e Mon Sep 17 00:00:00 2001 From: 0xYYBB | ZYY | Bobo <128128010+the-dev-z@users.noreply.github.com> Date: Sun, 16 Nov 2025 08:26:12 +0800 Subject: [PATCH] fix(docker): revert healthcheck to wget for Alpine compatibility (#986) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Problem PR #906 changed healthcheck commands from `wget` to `curl`, but Alpine Linux (our base image) does not include `curl` by default, causing all containers to fail healthchecks with: ``` exec: "curl": executable file not found in $PATH ``` This creates a configuration mismatch: - docker/Dockerfile.backend uses `wget` (✅ works) - docker-compose.yml uses `curl` (❌ fails) ## Root Cause Analysis Alpine Linux philosophy is minimalism: - ✅ `wget` is pre-installed (part of busybox) - ❌ `curl` requires `apk add curl` (~3MB extra) The original PR #906 made two commits: 1. First commit (3af8760): `curl` → `wget` (✅ correct fix) 2. Second commit (333b2ef): `wget` → `curl` (❌ introduced bug) The second commit was based on incorrect assumption that "curl is more widely available than wget in Docker images". This is false for Alpine. ## Solution Revert healthcheck commands back to `wget` to match: 1. Alpine's pre-installed tools 2. Dockerfile.backend healthcheck (line 68) 3. Docker and Kubernetes best practices ## Testing ✅ Verified `wget` exists in Alpine containers: ```bash docker run --rm alpine:latest which wget # Output: /usr/bin/wget ``` ✅ Added new CI workflow to prevent regression: - `.github/workflows/pr-docker-compose-healthcheck.yml` - Validates healthcheck compatibility with Alpine - Ensures containers reach healthy status ## Impact - **Before**: Containers show (unhealthy), potential auto-restart loops - **After**: Containers show (healthy), monitoring systems happy - **Scope**: Only affects docker-compose deployments - **Breaking**: None - this is a bug fix ## References - PR #906: Original (incorrect) fix - Alpine Linux: https://alpinelinux.org/about/ - Dockerfile.backend L68: Existing `wget` healthcheck 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: the-dev-z Co-authored-by: tinkle-community Co-authored-by: Shui <88711385+hzb1115@users.noreply.github.com> --- .../pr-docker-compose-healthcheck.yml | 152 ++++++++++++++++++ docker-compose.yml | 4 +- 2 files changed, 154 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/pr-docker-compose-healthcheck.yml diff --git a/.github/workflows/pr-docker-compose-healthcheck.yml b/.github/workflows/pr-docker-compose-healthcheck.yml new file mode 100644 index 00000000..139477e5 --- /dev/null +++ b/.github/workflows/pr-docker-compose-healthcheck.yml @@ -0,0 +1,152 @@ +name: PR Docker Compose Healthcheck + +# 驗證 docker-compose.yml 的 healthcheck 配置在 Alpine 容器中正常工作 +on: + pull_request: + branches: + - main + - dev + paths: + - 'docker-compose.yml' + - 'docker/Dockerfile.backend' + - 'docker/Dockerfile.frontend' + - '.github/workflows/pr-docker-compose-healthcheck.yml' + +jobs: + healthcheck-test: + name: Test Docker Compose Healthcheck + runs-on: ubuntu-22.04 + timeout-minutes: 10 + permissions: + contents: read + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Create minimal .env for testing + run: | + cat > .env < config.json <