From 0f858ea9acdbd7d4ddd9776e1363aba653d67035 Mon Sep 17 00:00:00 2001 From: yuluo-yx Date: Sat, 20 Sep 2025 14:31:36 +0800 Subject: [PATCH] feat: fix precommit container erro Signed-off-by: yuluo-yx --- Dockerfile.precommit | 6 ++++-- tools/make/pre-commit.mk | 24 ++++++++++++++++++++++-- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/Dockerfile.precommit b/Dockerfile.precommit index ec6ead26..dbd787c4 100644 --- a/Dockerfile.precommit +++ b/Dockerfile.precommit @@ -6,6 +6,8 @@ RUN apt-get update && apt-get install -y \ build-essential \ pkg-config \ python3 \ + libssl-dev \ + ca-certificates \ python3-pip # Install Node.js and npm @@ -13,8 +15,8 @@ RUN curl -fsSL https://deb.nodesource.com/setup_lts.x | bash - && \ apt-get install -y nodejs # Install Rust -RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y && \ - . $HOME/.cargo/env +RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y +ENV PATH="/root/.cargo/bin:${PATH}" # Markdown RUN npm install -g markdownlint-cli diff --git a/tools/make/pre-commit.mk b/tools/make/pre-commit.mk index 97735adf..e5322e58 100644 --- a/tools/make/pre-commit.mk +++ b/tools/make/pre-commit.mk @@ -1,3 +1,5 @@ +PRECOMMIT_CONTAINER := ghcr.io/vllm-project/semantic-router/precommit:latest + precommit-install: pip install pre-commit @@ -19,6 +21,24 @@ precommit-check: echo "No Go, Rust, JavaScript, Markdown, Yaml, or Python files found to check"; \ fi +# Run pre-commit hooks in a Docker container, +# and you can exec container to run bash for debug. +# export PRECOMMIT_CONTAINER=ghcr.io/vllm-project/semantic-router/precommit:latest +# docker run --rm -it \ +# -v $(pwd):/app \ +# -w /app \ +# --name precommit-container ${PRECOMMIT_CONTAINER} \ +# bash +# and then, run `pre-commit install && pre-commit run --all-files` command precommit-local: - docker pull ghcr.io/vllm/semantic-router/precommit:latest - docker run --rm -v $$(pwd):/data ghcr.io/vllm-project/semantic-router/precommit:latest pre-commit run --all-files + @if ! docker image inspect ${PRECOMMIT_CONTAINER} > /dev/null 2>&1; then \ + echo "Image not found locally. Pulling..."; \ + docker pull ${PRECOMMIT_CONTAINER}; \ + else \ + echo "Image found locally. Skipping pull."; \ + fi + docker run --rm \ + -v $(shell pwd):/app \ + -w /app \ + --name precommit-container ${PRECOMMIT_CONTAINER} \ + bash -c "source ~/.cargo/env && pre-commit install && pre-commit run --all-files"