|
| 1 | +# Multi-stage build to reduce final image size |
| 2 | +FROM docker:27.5.1 AS builder |
| 3 | + |
| 4 | +# Build dependencies (only needed during pip install) |
| 5 | +RUN apk add --no-cache python3 py3-pip python3-dev musl-dev gcc libffi-dev rust cargo |
| 6 | + |
| 7 | +WORKDIR /opt/opik-python-backend |
| 8 | +COPY requirements.txt . |
| 9 | + |
| 10 | +# Install Python packages in virtual environment for easy copying |
| 11 | +RUN python3 -m venv /opt/venv |
| 12 | +ENV PATH="/opt/venv/bin:$PATH" |
| 13 | +RUN pip install --no-cache-dir -r requirements.txt |
| 14 | + |
| 15 | +############################################################## |
| 16 | +# Runtime stage - minimal packages only |
1 | 17 | FROM docker:27.5.1
|
2 | 18 |
|
3 |
| -RUN apk add --no-cache tini python3 py3-pip python3-dev musl-dev gcc libffi-dev rust cargo |
| 19 | +# Only runtime dependencies needed |
| 20 | +RUN apk add --no-cache tini python3 |
4 | 21 |
|
5 | 22 | WORKDIR /opt/opik-python-backend
|
6 | 23 |
|
7 |
| -COPY requirements.txt . |
8 |
| -RUN pip install --no-cache-dir -r requirements.txt --break-system-packages |
| 24 | +# Copy the virtual environment from builder stage |
| 25 | +COPY --from=builder /opt/venv /opt/venv |
| 26 | +ENV PATH="/opt/venv/bin:$PATH" |
9 | 27 |
|
10 | 28 | ENV PYTHON_CODE_EXECUTOR_ASSET_NAME="opik-sandbox-executor-python"
|
11 | 29 | # Optionally copies the file. It's built ok without it, as it'll be pulled before running anyway.
|
@@ -34,4 +52,5 @@ ENV PYTHON_CODE_EXECUTOR_ALLOW_NETWORK=false
|
34 | 52 | ENV OPIK_VERSION=${OPIK_VERSION}
|
35 | 53 |
|
36 | 54 | ENTRYPOINT ["tini", "--"]
|
37 |
| -CMD ./entrypoint.sh |
| 55 | + |
| 56 | +CMD ["./entrypoint.sh"] |
0 commit comments