-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathDockerfile
More file actions
38 lines (29 loc) · 1.61 KB
/
Dockerfile
File metadata and controls
38 lines (29 loc) · 1.61 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
####################################################################################################
# Stage 1: Builder - installs all dependencies using uv
####################################################################################################
FROM ghcr.io/astral-sh/uv:python3.13-trixie AS builder
ENV PYSETUP_PATH="/opt/pysetup"
WORKDIR $PYSETUP_PATH
COPY pyproject.toml uv.lock README.md ./
COPY pynumaflow/ ./pynumaflow/
ENV EXAMPLE_PATH="$PYSETUP_PATH/examples/source/simple_source"
COPY examples/source/simple_source/ $EXAMPLE_PATH/
WORKDIR $EXAMPLE_PATH
RUN uv sync --no-dev --no-install-project --frozen
####################################################################################################
# Stage 2: Runtime - clean image with only installed packages
####################################################################################################
FROM ghcr.io/astral-sh/uv:python3.13-trixie AS udf
ENV PYSETUP_PATH="/opt/pysetup"
ENV EXAMPLE_PATH="$PYSETUP_PATH/examples/source/simple_source"
WORKDIR $EXAMPLE_PATH
COPY --from=builder $EXAMPLE_PATH/.venv $EXAMPLE_PATH/.venv
COPY --from=builder $EXAMPLE_PATH/ $EXAMPLE_PATH/
# NOTE: We cannot use "uv run python example.py" here because uv run reads the
# example's pyproject.toml, finds the pynumaflow path source (path = "../../../"),
# and tries to resolve it. In the runtime stage, the parent pynumaflow source tree
# is not present (by design, to keep the image small), so uv run fails.
# Instead, we activate the pre-built .venv via PATH and run python directly.
ENV PATH="$EXAMPLE_PATH/.venv/bin:$PATH"
CMD ["python", "example.py"]
EXPOSE 5000