Skip to content

Commit 01ab992

Browse files
committed
Offline Python worker
1 parent 243c8f7 commit 01ab992

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

dockerfiles/python.Dockerfile

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
# Build in a full featured container
22
ARG TARGETARCH
3+
ARG UV_IMAGE=ghcr.io/astral-sh/uv:latest
4+
FROM --platform=linux/$TARGETARCH ${UV_IMAGE} AS uv
35
FROM --platform=linux/$TARGETARCH python:3.11-bullseye AS build
46

57
# Install protobuf compiler
68
RUN apt-get update \
7-
&& DEBIAN_FRONTEND=noninteractive \
9+
&& DEBIAN_FRONTEND=noninteractive \
810
apt-get install --no-install-recommends --assume-yes \
9-
protobuf-compiler=3.12.4-1+deb11u1 libprotobuf-dev=3.12.4-1+deb11u1
11+
protobuf-compiler=3.12.4-1+deb11u1 libprotobuf-dev=3.12.4-1+deb11u1
1012

1113
# Get go compiler
1214
ARG TARGETARCH
@@ -20,7 +22,7 @@ RUN wget -q -O - https://sh.rustup.rs | sh -s -- -y
2022
ENV PATH="$PATH:/root/.cargo/bin"
2123

2224
# Install uv
23-
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
25+
COPY --from=uv /uv /uvx /bin/
2426

2527
WORKDIR /app
2628

@@ -46,12 +48,21 @@ COPY workers/python ./workers/python
4648
# Build the worker
4749
RUN CGO_ENABLED=0 ./temporal-omes prepare-worker --language python --dir-name prepared --version "$SDK_VERSION"
4850

51+
# Download the worker dependencies
52+
WORKDIR /app/workers/python/prepared
53+
RUN uv lock \
54+
&& uv sync --frozen \
55+
&& . .venv/bin/activate && python -m compileall -q .
56+
4957
# Copy the CLI and built worker to a distroless "run" container
5058
FROM --platform=linux/$TARGETARCH python:3.11-slim-bullseye
5159

52-
COPY --from=build /bin/uv /bin/uv
60+
COPY --from=uv /uv /uvx /bin/
5361
COPY --from=build /app/temporal-omes /app/temporal-omes
5462
COPY --from=build /app/workers/python /app/workers/python
5563

64+
ENV UV_OFFLINE=1 UV_FROZEN=1 UV_NO_SYNC=1 UV_ISOLATED=1 UV_PROJECT_ENVIRONMENT="/app/workers/python/prepared/.venv"
65+
ENV PATH="/app/workers/python/prepared/.venv/bin:${PATH}"
66+
5667
# Put the language and dir, but let other options (like required scenario and run-id) be given by user
5768
ENTRYPOINT ["/app/temporal-omes", "run-worker", "--language", "python", "--dir-name", "prepared"]

0 commit comments

Comments
 (0)