Skip to content

Commit 3a1b507

Browse files
committed
Migrate to uv
1 parent f630df6 commit 3a1b507

6 files changed

Lines changed: 724 additions & 1036 deletions

File tree

.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
__pycache__
2+
.venv

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
.env
2-
compose.override.yml
2+
compose.override.yml
3+
__pycache__
4+
.venv/

Dockerfile

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,26 @@
11
# Python app
22
FROM python:3.12-slim-bookworm
33

4-
ENV POETRY_VERSION=2.1.3
4+
ENV UV_VERSION=2.1.3
55
ENV PYTHONBUFFERED=1
6-
ENV POETRY_INSTALLER_MAX_WORKERS=1
7-
ENV POETRY_VIRTUALENVS_IN_PROJECT=false
8-
ENV POETRY_VIRTUALENVS_CREATE=false
6+
ENV UV_PROJECT_ENVIRONMENT=/venv
97

108
RUN apt update \
11-
&& apt install -y \
12-
curl \
13-
libffi-dev \
14-
&& curl -sSL https://install.python-poetry.org | python - --version ${POETRY_VERSION} \
15-
&& apt remove -y --autoremove --purge curl libffi-dev \
16-
&& apt clean && rm -rf /var/lib/apt/lists/*
9+
&& apt-get install -y --no-install-recommends \
10+
ca-certificates \
11+
&& apt-get clean && rm -rf /var/lib/apt/lists/*
1712

18-
ENV PATH="/root/.local/bin:$PATH"
13+
COPY --from=ghcr.io/astral-sh/uv:0.9.0 /uv /uvx /bin/
1914

2015
WORKDIR /code
2116

22-
COPY ./pyproject.toml ./poetry.lock /code/
23-
RUN poetry install --no-interaction --no-root --only=main
17+
COPY ./pyproject.toml ./uv.lock /code/
18+
RUN uv sync --locked
2419

2520
ARG BUILD_COMMIT_SHA
2621
ENV BUILD_COMMIT_SHA=${BUILD_COMMIT_SHA:-}
2722

28-
#RUN if [ "${BUILD_COMMIT_SHA}" = "localdev" ]; then \
29-
# poetry install --no-interaction --no-root --only=dev; \
30-
# fi
31-
3223
COPY . /code
3324
ENV PYTHONUNBUFFERED=0
3425

35-
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "80"]
36-
26+
CMD ["uv", "run", "--no-sync", "uvicorn", "main:app", "--host", "0.0.0.0", "--port", "80"]

0 commit comments

Comments
 (0)