@@ -9,29 +9,35 @@ ENV POETRY_NO_INTERACTION=1 \
99
1010COPY pyproject.toml poetry.lock ./
1111
12+ # Install dependencies and clean up in same layer
1213RUN --mount=type=cache,target=$POETRY_CACHE_DIR \
13- poetry install --without dev --no-root
14+ poetry install --without dev --no-root && \
15+ # Remove unnecessary files from venv to reduce size
16+ find /app/.venv -name "*.pyc" -delete && \
17+ find /app/.venv -name "__pycache__" -type d -exec rm -rf {} + && \
18+ find /app/.venv -name "*.pyo" -delete && \
19+ # Remove test files and documentation
20+ find /app/.venv -path "*/tests/*" -delete && \
21+ find /app/.venv -path "*/test/*" -delete && \
22+ find /app/.venv -name "*.md" -delete && \
23+ find /app/.venv -name "*.txt" -delete
1424
1525FROM ghcr.io/lambda-feedback/evaluation-function-base/python:3.12
1626
1727ENV VIRTUAL_ENV=/app/.venv \
1828 PATH="/app/.venv/bin:$PATH"
1929
30+ # Copy the cleaned virtual environment
2031COPY --from=builder ${VIRTUAL_ENV} ${VIRTUAL_ENV}
2132
22- # Precompile python files for faster startup
23- RUN python -m compileall -q .
24-
25- # Copy the evaluation function to the app directory
33+ # Copy evaluation function first (smaller, changes more often)
2634COPY evaluation_function ./evaluation_function
2735
28- # Command to start the evaluation function with
29- ENV FUNCTION_COMMAND="python"
30-
31- # Args to start the evaluation function with
32- ENV FUNCTION_ARGS="-m,evaluation_function.main"
33-
34- # The transport to use for the RPC server
35- ENV FUNCTION_RPC_TRANSPORT="ipc"
36+ # Precompile python files for faster startup (do this last)
37+ RUN python -m compileall -q .
3638
37- ENV LOG_LEVEL="debug"
39+ # Environment variables
40+ ENV FUNCTION_COMMAND="python" \
41+ FUNCTION_ARGS="-m,evaluation_function.main" \
42+ FUNCTION_RPC_TRANSPORT="ipc" \
43+ LOG_LEVEL="debug"
0 commit comments