1- FROM python:3 .13-slim- bookworm
1+ FROM ghcr.io/astral-sh/uv:python3 .13-bookworm-slim
22
3- ENV PYTHONUNBUFFERED 1
4- ENV PYTHONDONTWRITEBYTECODE 1
3+ ENV PYTHONUNBUFFERED=1
54
65RUN apt-get update \
76 # dependencies for building Python packages
@@ -10,24 +9,26 @@ RUN apt-get update \
109 && apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \
1110 && rm -rf /var/lib/apt/lists/*
1211
13- # Requirements are installed here to ensure they will be cached.
14- COPY ./translator/requirements /requirements
15- RUN pip install uv
16- RUN uv pip install --system -r /requirements/base.txt
12+ WORKDIR /app
1713
18- RUN mkdir /app \
19- && cd /app \
20- && git clone -b v3.33.0 https://github.com/osrg/gobgp.git \
21- && cd gobgp/api \
22- && python3 -m grpc_tools.protoc -I./ --python_out=/app/ --pyi_out=/app/ --grpc_python_out=/app/ *.proto
14+ COPY ./translator/pyproject.toml ./translator/uv.lock* ./
2315
24- COPY ./translator/translator.py /app
25- COPY ./translator/gobgp.py /app
26- COPY ./translator/exceptions.py /app
27- COPY ./translator/shared.py /app
16+ # Install deps only (as protobuf stuff doesn't exist yet but we need deps to setup protobufs)
17+ RUN uv sync --locked --no-install-project
2818
29- RUN chmod +x /app/translator.py
19+ # put the venv into PATH
20+ ENV PATH="/app/.venv/bin:$PATH"
3021
31- WORKDIR /app
22+ COPY ./translator/src /app/
23+
24+ # Generate protobuf files
25+ # TODO: Make this less jank and don't do the git clone crap?
26+ RUN git clone -b v3.33.0 https://github.com/osrg/gobgp.git gobgp \
27+ && cd gobgp/api \
28+ && python3 -m grpc_tools.protoc -I./ --python_out=/app/translator/ --pyi_out=/app/translator/ --grpc_python_out=/app/translator/ *.proto \
29+ && cd /app && rm -rf gobgp
30+
31+ # Install the project itself (including the protobuff stuff)
32+ RUN uv sync --locked
3233
33- ENTRYPOINT ["/app/ translator.py " ]
34+ ENTRYPOINT ["python" , "-m" , " translator.translator " ]
0 commit comments