diff --git a/Dockerfile b/Dockerfile index b3f28da..c7a62b2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -39,13 +39,19 @@ RUN uv venv /build/venv --python python3.10 && \ uv pip install -i https://pypi.tuna.tsinghua.edu.cn/simple -e . && \ 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 && \ 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 "*.pyo" -delete && \ 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 @@ -99,8 +105,8 @@ RUN mkdir -p /root/.cache/modelscope \ /root/.paddlex && \ rm -rf /app/app/model/* -# Declare volumes for model cache (mount at runtime to avoid re-downloading) -VOLUME ["/root/.cache/modelscope", "/root/.cache/huggingface", "/root/.paddlex"] +# NOTE: Do NOT declare VOLUME here - let users mount volumes explicitly at runtime +# This prevents anonymous volumes and keeps the image clean # Expose port EXPOSE 8053