-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
executable file
·56 lines (42 loc) · 1.91 KB
/
Copy pathDockerfile
File metadata and controls
executable file
·56 lines (42 loc) · 1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
FROM ghcr.io/lambda-feedback/evaluation-function-base/python:3.12 AS builder
RUN pip install poetry==2.2.1
ENV POETRY_NO_INTERACTION=1 \
POETRY_VIRTUALENVS_IN_PROJECT=1 \
POETRY_VIRTUALENVS_CREATE=1 \
POETRY_CACHE_DIR=/tmp/poetry_cache
COPY pyproject.toml poetry.lock ./
# Install dependencies and clean up in same layer
RUN --mount=type=cache,target=$POETRY_CACHE_DIR \
poetry install --without dev --no-root && \
# Remove unnecessary files from venv to reduce size
find /app/.venv -name "*.pyc" -delete && \
find /app/.venv -name "__pycache__" -type d -exec rm -rf {} + && \
find /app/.venv -name "*.pyo" -delete && \
# Remove test files and documentation
find /app/.venv -path "*/tests/*" -delete && \
find /app/.venv -path "*/test/*" -delete && \
find /app/.venv -name "*.md" -delete && \
find /app/.venv -name "*.txt" -delete
FROM ghcr.io/lambda-feedback/evaluation-function-base/python:3.12
ENV VIRTUAL_ENV=/app/.venv \
PATH="/app/.venv/bin:$PATH"
# Copy the cleaned virtual environment
COPY --from=builder ${VIRTUAL_ENV} ${VIRTUAL_ENV}
# Copy evaluation function first (smaller, changes more often)
COPY evaluation_function ./evaluation_function
# Precompile python files for faster startup (do this last)
RUN python -m compileall -q .
# Environment variables
# Command to start the evaluation function with
ENV FUNCTION_COMMAND="python"
# Args to start the evaluation function with
ENV FUNCTION_ARGS="-m,evaluation_function.main"
ENV FUNCTION_INTERFACE="rpc"
ENV FUNCTION_RPC_TRANSPORT="stdio"
# The worker pulls in torch on its first request; on a small (1024 MB) Lambda
# that cold-start import runs ~30-40s. Give shimmy room to wait for it instead
# of killing the half-booted worker at the 30s default. Keep these below the
# Lambda function timeout (currently 175s).
ENV FUNCTION_WORKER_START_TIMEOUT="150s"
ENV FUNCTION_WORKER_SEND_TIMEOUT="150s"
ENV LOG_LEVEL="debug"