From 46566ebfa51e54d9d33f0f6429c4bdac57f6d942 Mon Sep 17 00:00:00 2001 From: AdrianoDev Date: Sun, 16 Aug 2026 19:43:20 +0200 Subject: [PATCH] fix(vision): build fallisce senza VISION_ENGINE_VERSION, healthcheck vero MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Un build senza la variabile produceva un'immagine che partiva e rispondeva "healthy" pur fallendo ogni richiesta, /health incluso: non c'era un healthcheck a dirlo. Tre correzioni: RUN test -n "$VISION_ENGINE_VERSION" in Dockerfile.vision dopo l'ARG, fallisce subito con il comando da lanciare; healthcheck su /health nel servizio vision di entrambi i compose; VISION_ENGINE_VERSION documentata in .env.example accanto a VISION_WORKER_URL, che giĆ  c'era. Verificato con docker build reale: senza la variabile fallisce al passo del test con il messaggio atteso; con la variabile impostata l'immagine si costruisce, il container parte, e python3 -c "urllib.request.urlopen('http://localhost:8100/health')" - lo stesso comando usato nell'healthcheck - risponde 200 con l'engine_version giusta. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_014BBnuACZSCJqXrMYC3LUMU --- .env.example | 5 +++++ Dockerfile.vision | 8 ++++++++ docker-compose.dev.yml | 6 ++++++ docker-compose.yml | 6 ++++++ 4 files changed, 25 insertions(+) diff --git a/.env.example b/.env.example index 60ef3e7..5b3237c 100644 --- a/.env.example +++ b/.env.example @@ -33,6 +33,11 @@ STATION_SWITCH_ENABLED=0 # --- Vision --- # Internal address of the vision worker. Never exposed outside tmflow-net. VISION_WORKER_URL=http://vision:8100 +# The pinned VisionSuite commit, stamped into the vision image at build time +# (Dockerfile.vision ARG). Required: `docker compose build vision` fails +# immediately without it. Set with: +# VISION_ENGINE_VERSION=$(git -C vendor/visionsuite rev-parse HEAD) +VISION_ENGINE_VERSION= # --- File Storage --- # Resolved against the project root in src/backend/config.py. diff --git a/Dockerfile.vision b/Dockerfile.vision index d44d00a..7e29cb1 100644 --- a/Dockerfile.vision +++ b/Dockerfile.vision @@ -24,6 +24,14 @@ COPY src/vision_worker/ ./src/vision_worker/ # VISION_ENGINE_VERSION=$(git -C vendor/visionsuite rev-parse HEAD) \ # docker compose build vision ARG VISION_ENGINE_VERSION +# I4: a build without the commit must fail now, at build time - not later, at +# every request including /health, with a container Docker still reports as +# healthy because no healthcheck existed to say otherwise. +RUN test -n "$VISION_ENGINE_VERSION" || { \ + echo "VISION_ENGINE_VERSION is required. Build with:"; \ + echo ' VISION_ENGINE_VERSION=$(git -C vendor/visionsuite rev-parse HEAD) docker compose build vision'; \ + exit 1; \ + } ENV VISION_ENGINE_VERSION=${VISION_ENGINE_VERSION} EXPOSE 8100 diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml index 46b54f6..8eb1b35 100644 --- a/docker-compose.dev.yml +++ b/docker-compose.dev.yml @@ -50,6 +50,12 @@ services: VISION_ENGINE_VERSION: ${VISION_ENGINE_VERSION:-} container_name: tmflow-vision restart: unless-stopped + healthcheck: + test: ["CMD", "python3", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:8100/health', timeout=5)"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 20s networks: - tmflow-net diff --git a/docker-compose.yml b/docker-compose.yml index b3ead40..57d5c71 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -59,6 +59,12 @@ services: VISION_ENGINE_VERSION: ${VISION_ENGINE_VERSION:-} container_name: tmflow-vision restart: unless-stopped + healthcheck: + test: ["CMD", "python3", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:8100/health', timeout=5)"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 20s networks: - tmflow-net