File tree Expand file tree Collapse file tree 1 file changed +21
-4
lines changed Expand file tree Collapse file tree 1 file changed +21
-4
lines changed Original file line number Diff line number Diff line change
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
1
16
FROM docker:27.5.1
2
17
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
4
20
5
21
WORKDIR /opt/opik-python-backend
6
22
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"
9
26
10
27
ENV PYTHON_CODE_EXECUTOR_ASSET_NAME="opik-sandbox-executor-python"
11
28
# 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
34
51
ENV OPIK_VERSION=${OPIK_VERSION}
35
52
36
53
ENTRYPOINT ["tini" , "--" ]
37
- CMD ./entrypoint.sh
54
+ CMD [ " ./entrypoint.sh" ]
You can’t perform that action at this time.
0 commit comments