fix: remove VOLUME declaration to prevent anonymous volumes

- Remove VOLUME directive that was creating anonymous volumes
- Keep directory creation (mkdir) for runtime mount points
- Users must explicitly mount volumes with -v flags
- This prevents hidden volume bloat in docker exec

Usage:
  docker run --gpus all -p 8053:8053 \
    -v /home/yoge/.cache/modelscope:/root/.cache/modelscope:ro \
    -v /home/yoge/.cache/huggingface:/root/.cache/huggingface:ro \
    -v /home/yoge/.paddlex:/root/.paddlex:ro \
    doc_processer:latest

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
liuyuanchuang
2026-03-10 11:12:01 +08:00
parent 6579cf55f5
commit 95c497829f

View File

@@ -39,13 +39,19 @@ RUN uv venv /build/venv --python python3.10 && \
uv pip install -i https://pypi.tuna.tsinghua.edu.cn/simple -e . && \ uv pip install -i https://pypi.tuna.tsinghua.edu.cn/simple -e . && \
rm -rf ./wheels rm -rf ./wheels
# Clean up venv - remove unnecessary files # Aggressively clean up venv - remove all cache and unnecessary files
RUN find /build/venv -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null || true && \ RUN find /build/venv -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null || true && \
find /build/venv -type d -name "*.dist-info/tests" -exec rm -rf {} + 2>/dev/null || true && \ find /build/venv -type d -name "*.dist-info/tests" -exec rm -rf {} + 2>/dev/null || true && \
find /build/venv -type f -name "*.pyc" -delete && \ find /build/venv -type f -name "*.pyc" -delete && \
find /build/venv -type f -name "*.pyo" -delete && \ find /build/venv -type f -name "*.pyo" -delete && \
find /build/venv -type d -name "tests" -exec rm -rf {} + 2>/dev/null || true && \ find /build/venv -type d -name "tests" -exec rm -rf {} + 2>/dev/null || true && \
find /build/venv -type d -name "test" -exec rm -rf {} + 2>/dev/null || true find /build/venv -type d -name "test" -exec rm -rf {} + 2>/dev/null || true && \
find /build/venv -type d -name "*.dist-info" -exec find {} -type f -name "RECORD" -delete \; && \
find /build/venv -type d -name "*.dist-info" -exec find {} -type f -name "top_level.txt" -delete \; && \
rm -rf /build/venv/lib/*/site-packages/pip* /build/venv/lib/*/site-packages/setuptools* && \
rm -rf /build/venv/lib/python*/site-packages/__pycache__ && \
rm -rf /build/venv/include /build/venv/share && \
rm -rf /root/.cache 2>/dev/null || true
# ============================================================================= # =============================================================================
# STAGE 2: Runtime - Minimal final image # STAGE 2: Runtime - Minimal final image
@@ -99,8 +105,8 @@ RUN mkdir -p /root/.cache/modelscope \
/root/.paddlex && \ /root/.paddlex && \
rm -rf /app/app/model/* rm -rf /app/app/model/*
# Declare volumes for model cache (mount at runtime to avoid re-downloading) # NOTE: Do NOT declare VOLUME here - let users mount volumes explicitly at runtime
VOLUME ["/root/.cache/modelscope", "/root/.cache/huggingface", "/root/.paddlex"] # This prevents anonymous volumes and keeps the image clean
# Expose port # Expose port
EXPOSE 8053 EXPOSE 8053