From 407443166e5efba5fc0945275fa7e94d694d88da Mon Sep 17 00:00:00 2001 From: Marius Maryniak Date: Mon, 14 Oct 2024 16:20:31 +0200 Subject: [PATCH] build: use uv in dockerfiles (#343) --- dev/dockerfiles/aviary.Dockerfile | 22 +++++++++++++++------- dev/dockerfiles/aviary_dev.Dockerfile | 13 +++++++++---- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/dev/dockerfiles/aviary.Dockerfile b/dev/dockerfiles/aviary.Dockerfile index d931572..d54462c 100644 --- a/dev/dockerfiles/aviary.Dockerfile +++ b/dev/dockerfiles/aviary.Dockerfile @@ -2,17 +2,18 @@ FROM python:3.12-slim as builder WORKDIR /aviary +COPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/uv COPY . . -RUN python -m pip install --upgrade pip setuptools wheel && \ - pip wheel --no-cache-dir --no-deps --wheel-dir wheels . +RUN uv venv venv && \ + . venv/bin/activate && \ + uv pip install --upgrade pip setuptools wheel && \ + uv build --wheel --no-cache . FROM python:3.12-slim as runner WORKDIR /aviary -COPY --from=builder /aviary/wheels wheels - ENV PYTHONUNBUFFERED 1 ARG VERSION @@ -26,11 +27,18 @@ LABEL org.opencontainers.image.title="aviary" \ org.opencontainers.image.source="https://www.github.com/geospaitial-lab/aviary" \ org.opencontainers.image.documentation="https://geospaitial-lab.github.io/aviary" -RUN python -m pip install --upgrade pip setuptools wheel && \ - pip install --no-cache-dir wheels/* && \ - rm -rf wheels && \ +COPY --from=builder /bin/uv /bin/uv +COPY --from=builder /aviary/venv /aviary/venv +COPY --from=builder /aviary/dist /aviary/dist + +RUN uv venv venv && \ + . venv/bin/activate && \ + uv pip install --no-cache dist/* && \ + rm -rf dist && \ adduser --disabled-password --gecos "" aviary_user USER aviary_user +ENV PATH="/aviary/venv/bin:$PATH" + ENTRYPOINT ["aviary"] diff --git a/dev/dockerfiles/aviary_dev.Dockerfile b/dev/dockerfiles/aviary_dev.Dockerfile index 5b6b866..400340e 100644 --- a/dev/dockerfiles/aviary_dev.Dockerfile +++ b/dev/dockerfiles/aviary_dev.Dockerfile @@ -2,8 +2,6 @@ FROM python:3.12-slim WORKDIR /aviary -COPY . . - ENV PYTHONUNBUFFERED 1 LABEL org.opencontainers.image.title="aviary" \ @@ -15,10 +13,17 @@ LABEL org.opencontainers.image.title="aviary" \ org.opencontainers.image.source="https://www.github.com/geospaitial-lab/aviary" \ org.opencontainers.image.documentation="https://geospaitial-lab.github.io/aviary" -RUN python -m pip install --upgrade pip setuptools wheel && \ - pip install --no-cache-dir . && \ +COPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/uv +COPY . . + +RUN uv venv venv && \ + . venv/bin/activate && \ + uv pip install --upgrade pip setuptools wheel && \ + uv pip install . && \ adduser --disabled-password --gecos "" aviary_user USER aviary_user +ENV PATH="/aviary/venv/bin:$PATH" + ENTRYPOINT ["aviary"]