Skip to content

Commit a6fbe28

Browse files
committed
switch to uv
1 parent a5f985c commit a6fbe28

File tree

5 files changed

+602
-890
lines changed

5 files changed

+602
-890
lines changed

.github/workflows/ci.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,14 @@ jobs:
4242
uses: actions/setup-python@v5
4343
with:
4444
python-version: "3.12"
45-
- name: Setup poetry
46-
uses: abatilo/actions-poetry@v2
45+
- name: Install uv
46+
uses: astral-sh/setup-uv@v5
4747
with:
48-
poetry-version: "1.8.3"
48+
version: "0.5.18"
4949
- name: Install dependencies
50-
run: poetry install --with=test
50+
run: uv sync --group=test
5151
- name: Run pytest
52-
run: poetry run pytest --cov=teufa --cov-report=xml tests/
52+
run: uv run pytest --cov=teufa --cov-report=xml tests/
5353
env:
5454
DATABASE_URL: postgresql+psycopg://postgres:postgres@localhost:5432/postgres
5555
- name: Upload coverage reports to Codecov

Dockerfile

+14-29
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
11
# syntax=docker/dockerfile:1
22

33
## base image
4-
FROM python:3.12-slim as base
4+
FROM python:3.12-slim AS base
55

66
ENV PYTHONUNBUFFERED=1 \
77
PYTHONDONTWRITEBYTECODE=1 \
8-
PIP_DISABLE_PIP_VERSION_CHECK=on \
9-
PIP_DEFAULT_TIMEOUT=100 \
10-
POETRY_VERSION="1.8.3" \
11-
POETRY_HOME="/opt/poetry" \
12-
POETRY_NO_INTERACTION=1 \
13-
VENV_PATH="/opt/venv" \
8+
VENV_PATH="/opt/app/.venv" \
149
APP_HOME="/opt/app"
15-
ENV PATH="$POETRY_HOME/bin:$VENV_PATH/bin:$PATH"
10+
ENV PATH="$VENV_PATH/bin:$PATH"
1611
ENV VIRTUAL_ENV=$VENV_PATH
1712

1813
RUN set -ex \
@@ -23,7 +18,7 @@ RUN set -ex \
2318

2419

2520
## builder-base image
26-
FROM base as builder-base
21+
FROM base AS builder-base
2722
RUN apt-get update && \
2823
apt-get install --no-install-recommends -y \
2924
curl \
@@ -32,32 +27,25 @@ RUN apt-get update && \
3227
python3-dev \
3328
&& rm -rf /var/lib/apt/lists/*
3429

35-
RUN --mount=type=cache,target=/root/.cache \
36-
curl -sSL https://install.python-poetry.org | python -
30+
COPY --from=ghcr.io/astral-sh/uv:0.5.18 /uv /uvx /bin/
3731

3832
WORKDIR $APP_HOME
39-
COPY poetry.lock pyproject.toml ./
33+
COPY uv.lock pyproject.toml ./
4034

41-
RUN --mount=type=cache,target=/root/.cache \
42-
python -m venv $VENV_PATH && \
43-
poetry install --no-root --only=main
35+
RUN uv sync --frozen
4436

4537
COPY . .
46-
RUN --mount=type=cache,target=/root/.cache \
47-
poetry install --only-root
4838

4939

5040
## dev image
51-
FROM base as dev
41+
FROM base AS dev
5242

53-
COPY --from=builder-base $POETRY_HOME $POETRY_HOME
54-
COPY --from=builder-base $VENV_PATH $VENV_PATH
5543
COPY --from=builder-base $APP_HOME $APP_HOME
44+
COPY --from=ghcr.io/astral-sh/uv:0.5.18 /uv /uvx /bin/
5645

5746
WORKDIR $APP_HOME
5847

59-
RUN --mount=type=cache,target=/root/.cache \
60-
poetry install --with=dev && \
48+
RUN uv sync --frozen --dev && \
6149
rm -rf $APP_HOME
6250

6351
EXPOSE 8000
@@ -67,22 +55,19 @@ CMD ["server", "--dev"]
6755

6856

6957
## ci image
70-
FROM base as ci
58+
FROM base AS ci
7159

72-
COPY --from=builder-base $POETRY_HOME $POETRY_HOME
73-
COPY --from=builder-base $VENV_PATH $VENV_PATH
7460
COPY --from=builder-base $APP_HOME $APP_HOME
61+
COPY --from=ghcr.io/astral-sh/uv:0.5.18 /uv /uvx /bin/
7562

7663
WORKDIR $APP_HOME
7764

78-
RUN --mount=type=cache,target=/root/.cache \
79-
poetry install --with=test
65+
RUN uv sync --frozen --group=test
8066

8167

8268
## prod image
83-
FROM base as prod
69+
FROM base AS prod
8470

85-
COPY --from=builder-base $VENV_PATH $VENV_PATH
8671
COPY --from=builder-base /opt/app /opt/app
8772

8873
WORKDIR $APP_HOME

0 commit comments

Comments
 (0)