Skip to content

Commit e018e7c

Browse files
yuluo-yxrootfs
andauthored
feat: fix precommit container erro (#182)
Signed-off-by: yuluo-yx <[email protected]> Co-authored-by: Huamin Chen <[email protected]>
1 parent 113dc52 commit e018e7c

File tree

2 files changed

+26
-4
lines changed

2 files changed

+26
-4
lines changed

Dockerfile.precommit

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,17 @@ RUN apt-get update && apt-get install -y \
66
build-essential \
77
pkg-config \
88
python3 \
9+
libssl-dev \
10+
ca-certificates \
911
python3-pip
1012

1113
# Install Node.js and npm
1214
RUN curl -fsSL https://deb.nodesource.com/setup_lts.x | bash - && \
1315
apt-get install -y nodejs
1416

1517
# Install Rust
16-
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y && \
17-
. $HOME/.cargo/env
18+
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
19+
ENV PATH="/root/.cargo/bin:${PATH}"
1820

1921
# Markdown
2022
RUN npm install -g markdownlint-cli

tools/make/pre-commit.mk

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
PRECOMMIT_CONTAINER := ghcr.io/vllm-project/semantic-router/precommit:latest
2+
13
precommit-install:
24
pip install pre-commit
35

@@ -19,6 +21,24 @@ precommit-check:
1921
echo "No Go, Rust, JavaScript, Markdown, Yaml, or Python files found to check"; \
2022
fi
2123

24+
# Run pre-commit hooks in a Docker container,
25+
# and you can exec container to run bash for debug.
26+
# export PRECOMMIT_CONTAINER=ghcr.io/vllm-project/semantic-router/precommit:latest
27+
# docker run --rm -it \
28+
# -v $(pwd):/app \
29+
# -w /app \
30+
# --name precommit-container ${PRECOMMIT_CONTAINER} \
31+
# bash
32+
# and then, run `pre-commit install && pre-commit run --all-files` command
2233
precommit-local:
23-
docker pull ghcr.io/vllm/semantic-router/precommit:latest
24-
docker run --rm -v $$(pwd):/data ghcr.io/vllm-project/semantic-router/precommit:latest pre-commit run --all-files
34+
@if ! docker image inspect ${PRECOMMIT_CONTAINER} > /dev/null 2>&1; then \
35+
echo "Image not found locally. Pulling..."; \
36+
docker pull ${PRECOMMIT_CONTAINER}; \
37+
else \
38+
echo "Image found locally. Skipping pull."; \
39+
fi
40+
docker run --rm \
41+
-v $(shell pwd):/app \
42+
-w /app \
43+
--name precommit-container ${PRECOMMIT_CONTAINER} \
44+
bash -c "source ~/.cargo/env && pre-commit install && pre-commit run --all-files"

0 commit comments

Comments
 (0)