From a8ce0a7559f019009d957836949bb0c89e664f2d Mon Sep 17 00:00:00 2001 From: Siddharth Kumar Sah Date: Tue, 14 Apr 2026 23:02:16 +0800 Subject: [PATCH] fix(docker): skip model downloads in CI to prevent HuggingFace CDN 504s MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Docker Build Test was consistently failing because HuggingFace CDN returns 504 Gateway Timeout when downloading the LaMa ONNX model (~200MB) from GitHub Actions runners. Model availability is an external dependency, not something CI can control. Added SKIP_MODEL_DOWNLOADS build arg (default: false). When set to true, the download_models.py step is skipped entirely. CI only needs to verify the image structure builds — Python deps install, Node build runs, app code is copied — not that every ML model CDN is reachable. Production builds (docker build without the arg) still download all models as before. --- .github/workflows/ci.yml | 1 + docker/Dockerfile | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ae1e3422..88937415 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -93,5 +93,6 @@ jobs: file: docker/Dockerfile push: false tags: ashim:ci + build-args: SKIP_MODEL_DOWNLOADS=true cache-from: type=gha,scope=unified cache-to: type=gha,mode=max,scope=unified diff --git a/docker/Dockerfile b/docker/Dockerfile index 49391572..ecc8eb69 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -63,6 +63,8 @@ ARG TARGETARCH FROM base-${TARGETOS}-${TARGETARCH} AS production ARG TARGETARCH +# Set to "true" to skip model downloads (for CI builds that just test the image structure) +ARG SKIP_MODEL_DOWNLOADS=false # Install Node.js on amd64 (CUDA base has no Node; arm64 base already has it) RUN if [ "$TARGETARCH" = "amd64" ]; then \ @@ -147,8 +149,14 @@ RUN /opt/venv/bin/pip install numpy==1.26.4 # Note: on amd64, paddlepaddle-gpu can't import without the CUDA driver (only # available at runtime). The download script gracefully skips PaddleOCR model # pre-download in this case; models download on first use at runtime instead. +# In CI (SKIP_MODEL_DOWNLOADS=true), skip downloads — the image structure is +# what matters for the build test; models are verified in integration tests. COPY docker/download_models.py /tmp/download_models.py -RUN /opt/venv/bin/python3 /tmp/download_models.py && rm -f /tmp/download_models.py +RUN if [ "$SKIP_MODEL_DOWNLOADS" = "true" ]; then \ + echo "Skipping model downloads (CI build)"; \ + else \ + /opt/venv/bin/python3 /tmp/download_models.py; \ + fi && rm -f /tmp/download_models.py WORKDIR /app