generated from lambda-feedback/evaluation-function-boilerplate-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
executable file
·47 lines (35 loc) · 1.52 KB
/
Dockerfile
File metadata and controls
executable file
·47 lines (35 loc) · 1.52 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
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="file"
ENV LOG_LEVEL="debug"