forked from NVlabs/alpasim
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgrpc.Dockerfile
More file actions
64 lines (47 loc) · 2.04 KB
/
Copy pathgrpc.Dockerfile
File metadata and controls
64 lines (47 loc) · 2.04 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# syntax=docker/dockerfile:1.7
# Slim image that ships only the alpasim_grpc Python package -- proto stubs and
# Python client/server bindings. No CUDA, no PyTorch, no Rust toolchain.
# Downstream E2E stacks that only need to speak gRPC to alpasim should depend
# on this image instead of the main alpasim-base image.
#
# Build (context is src/grpc, not the repo root):
# docker build -f grpc.Dockerfile -t alpasim-grpc-slim src/grpc
ARG PYTHON_VERSION=3.11
# Pinned via Renovate / manual bump; COPY --from cannot resolve ARGs.
FROM ghcr.io/astral-sh/uv:0.5.18 AS uv
# ---- builder ---------------------------------------------------------------
FROM ubuntu:22.04 AS builder
ARG PYTHON_VERSION
ENV DEBIAN_FRONTEND=noninteractive \
UV_LINK_MODE=copy \
UV_PYTHON_INSTALL_DIR=/opt/uv-python \
UV_PYTHON=${PYTHON_VERSION}
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
COPY --from=uv /uv /uvx /usr/local/bin/
WORKDIR /build
COPY . /build/
# hatch_build.py invokes grpc_tools.protoc, so .proto files are compiled into
# *_pb2.py / *_pb2_grpc.py / *.pyi and packed into the wheel automatically.
RUN --mount=type=cache,target=/root/.cache/uv \
uv build --wheel --out-dir /wheels
# ---- runtime ---------------------------------------------------------------
FROM ubuntu:22.04 AS runtime
ARG PYTHON_VERSION
ENV DEBIAN_FRONTEND=noninteractive \
UV_LINK_MODE=copy \
UV_PYTHON_INSTALL_DIR=/opt/uv-python \
PATH="/opt/alpasim-grpc/bin:${PATH}"
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
COPY --from=uv /uv /usr/local/bin/
RUN uv venv --python ${PYTHON_VERSION} /opt/alpasim-grpc
COPY --from=builder /wheels /wheels
RUN --mount=type=cache,target=/root/.cache/uv \
uv pip install --python /opt/alpasim-grpc/bin/python /wheels/*.whl \
&& rm -rf /wheels
RUN /opt/alpasim-grpc/bin/python -c "import alpasim_grpc; import alpasim_grpc.v0.egodriver_pb2"
WORKDIR /work
CMD ["python3"]