Skip to content

Commit e98dc31

Browse files
committed
Fix docker dependencies
1 parent 8d5336b commit e98dc31

File tree

1 file changed

+23
-4
lines changed

1 file changed

+23
-4
lines changed

apps/opik-python-backend/Dockerfile

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,29 @@
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
117
FROM docker:27.5.1
218

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
421

522
WORKDIR /opt/opik-python-backend
623

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"
927

1028
ENV PYTHON_CODE_EXECUTOR_ASSET_NAME="opik-sandbox-executor-python"
1129
# 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
3452
ENV OPIK_VERSION=${OPIK_VERSION}
3553

3654
ENTRYPOINT ["tini", "--"]
37-
CMD ./entrypoint.sh
55+
56+
CMD ["./entrypoint.sh"]

0 commit comments

Comments
 (0)