Skip to content

Commit 4f3c1a4

Browse files
committed
Fix docker dependencies
1 parent 8d5336b commit 4f3c1a4

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

apps/opik-python-backend/Dockerfile

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,28 @@
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+
# Runtime stage - minimal packages only
116
FROM docker:27.5.1
217

3-
RUN apk add --no-cache tini python3 py3-pip python3-dev musl-dev gcc libffi-dev rust cargo
18+
# Only runtime dependencies needed
19+
RUN apk add --no-cache tini python3
420

521
WORKDIR /opt/opik-python-backend
622

7-
COPY requirements.txt .
8-
RUN pip install --no-cache-dir -r requirements.txt --break-system-packages
23+
# Copy the virtual environment from builder stage
24+
COPY --from=builder /opt/venv /opt/venv
25+
ENV PATH="/opt/venv/bin:$PATH"
926

1027
ENV PYTHON_CODE_EXECUTOR_ASSET_NAME="opik-sandbox-executor-python"
1128
# Optionally copies the file. It's built ok without it, as it'll be pulled before running anyway.
@@ -34,4 +51,4 @@ ENV PYTHON_CODE_EXECUTOR_ALLOW_NETWORK=false
3451
ENV OPIK_VERSION=${OPIK_VERSION}
3552

3653
ENTRYPOINT ["tini", "--"]
37-
CMD ./entrypoint.sh
54+
CMD ["./entrypoint.sh"]

0 commit comments

Comments
 (0)