Skip to content

Commit

Permalink
build: use uv in dockerfiles (#343)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrsmrynk authored Oct 14, 2024
1 parent 40b14e9 commit 4074431
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 11 deletions.
22 changes: 15 additions & 7 deletions dev/dockerfiles/aviary.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"]
13 changes: 9 additions & 4 deletions dev/dockerfiles/aviary_dev.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ FROM python:3.12-slim

WORKDIR /aviary

COPY . .

ENV PYTHONUNBUFFERED 1

LABEL org.opencontainers.image.title="aviary" \
Expand All @@ -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"]

0 comments on commit 4074431

Please sign in to comment.