Skip to content

Commit f9759cf

Browse files
committed
Reduce image size and enhance caching
- Mount cache directory across layers when necessary. - Allow cache directory usage for pip command.
1 parent c7876bc commit f9759cf

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

docker/Dockerfile

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ RUN git clone $VLLM_REPO /workspace/vllm
2323
RUN if [ -n "$VLLM_COMMIT_HASH" ]; then \
2424
git checkout $VLLM_COMMIT_HASH; \
2525
fi
26-
RUN pip install -r requirements/tpu.txt --retries 3
27-
RUN VLLM_TARGET_DEVICE="tpu" pip install -e .
26+
RUN --mount=type=cache,target=/root/.cache/pip pip install -r requirements/tpu.txt --retries 3
27+
RUN --mount=type=cache,target=/root/.cache/pip VLLM_TARGET_DEVICE="tpu" pip install -e .
2828

2929
# Install test dependencies
30-
RUN python3 -m pip install -e tests/vllm_test_utils
31-
RUN python3 -m pip install --no-cache-dir \
30+
RUN --mount=type=cache,target=/root/.cache/pip python3 -m pip install -e tests/vllm_test_utils
31+
RUN --mount=type=cache,target=/root/.cache/pip python3 -m pip install \
3232
git+https://github.com/thuml/depyf.git \
3333
pytest-asyncio \
3434
git+https://github.com/EleutherAI/lm-evaluation-harness.git@206b7722158f58c35b7ffcd53b035fdbdda5126d#egg=lm-eval[api] \
@@ -39,18 +39,18 @@ RUN python3 -m pip install --no-cache-dir \
3939
WORKDIR /workspace/tpu_inference
4040
# Install requirements first and cache so we don't need to re-install on code change.
4141
COPY requirements.txt .
42-
RUN pip install -r requirements.txt --retries 3
42+
RUN --mount=type=cache,target=/root/.cache/pip pip install -r requirements.txt --retries 3
4343
COPY requirements_benchmarking.txt .
4444
# These are needed for the E2E benchmarking tests (i.e. tests/e2e/benchmarking/mlperf.sh)
45-
RUN pip install -r requirements_benchmarking.txt --retries 3
45+
RUN --mount=type=cache,target=/root/.cache/pip pip install -r requirements_benchmarking.txt --retries 3
4646
COPY . .
47-
RUN pip install -e .
47+
RUN --mount=type=cache,target=/root/.cache/pip pip install -e .
4848

4949
# TODO (jacobplatin): remove when v7x is supported in JAX/Libtpu officially
5050
# NOTE: it's important that this is done after installing tpu_inference above,
5151
# so that the v7x-specific dependencies can override any existing ones.
5252
COPY requirements_v7x.txt .
53-
RUN if [ "$IS_FOR_V7X" = "true" ]; then \
53+
RUN --mount=type=cache,target=/root/.cache/pip if [ "$IS_FOR_V7X" = "true" ]; then \
5454
pip install -r requirements_v7x.txt; \
5555
fi
5656

0 commit comments

Comments
 (0)