Skip to content

Commit 2a0637e

Browse files
committed
Transfered the project itself to UV.
1 parent b01687b commit 2a0637e

File tree

8 files changed

+947
-1113
lines changed

8 files changed

+947
-1113
lines changed

.github/workflows/release.yml

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,29 +9,28 @@ jobs:
99
pypi:
1010
runs-on: ubuntu-latest
1111
steps:
12-
- uses: actions/checkout@v2
13-
- name: Install poetry
14-
run: pipx install poetry
12+
- uses: actions/checkout@v5
1513
- name: Set up Python
16-
uses: actions/setup-python@v4
14+
uses: actions/setup-python@v6
1715
with:
18-
python-version: "3.11"
19-
- name: Install deps
20-
run: poetry install
21-
- name: Set version
22-
run: poetry version "${{ github.ref_name }}"
16+
python-version: "3.12"
17+
- name: Install the latest version of uv
18+
uses: astral-sh/setup-uv@v7
2319
- name: Release package
2420
env:
25-
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }}
26-
run: poetry publish --build
21+
UV_PUBLISH_TOKEN: ${{ secrets.PYPI_TOKEN }}
22+
run: |
23+
uv version "${{ github.ref_name }}"
24+
uv build
25+
uv publish
2726
docker:
2827
runs-on: ubuntu-latest
2928
permissions:
3029
packages: write
3130
contents: read
3231
steps:
3332
- name: Checkout
34-
uses: actions/checkout@v4
33+
uses: actions/checkout@v5
3534
- name: Set up Docker
3635
uses: docker/setup-qemu-action@v3
3736
- name: Set up Docker Buildx

.github/workflows/test.yml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,16 @@ jobs:
2525
steps:
2626
- uses: actions/checkout@v4
2727
- name: Set up Python
28-
uses: actions/setup-python@v2
28+
uses: actions/setup-python@v6
2929
with:
3030
python-version: '3.12'
31-
- name: Install deps
32-
run: |
33-
pip install -U pip
34-
pip install poetry==1.8.2
35-
poetry install
3631
env:
3732
POETRY_VIRTUALENVS_CREATE: "False"
33+
- name: Set up UV
34+
uses: astral-sh/setup-uv@v6
3835
- name: Setup GIT
3936
run: |
4037
git config --global user.name "fastapi_template"
4138
git config --global user.email "fastapi_template@pytest.python"
4239
- name: Run tests
43-
run: pytest -vv -n auto
40+
run: uv run pytest -vv -n auto

Dockerfile

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
FROM python:3.11.4-alpine
1+
FROM ghcr.io/astral-sh/uv:0.9.12-python3.13-alpine
22

3-
RUN apk add --no-cache \
3+
RUN apk update && apk add --no-cache \
44
curl \
55
# For building dependencies. \
66
gcc \
@@ -16,23 +16,27 @@ RUN apk add --no-cache \
1616
ncurses \
1717
bash
1818

19-
RUN adduser --disabled-password fastapi_template
19+
RUN adduser -u 1000 --disabled-password fastapi_template
2020
RUN mkdir /projects /src
21-
RUN chown -R fastapi_template:fastapi_template /projects /src
22-
USER fastapi_template
2321

24-
WORKDIR /src
22+
ENV UV_COMPILE_BYTECODE=1
23+
ENV UV_LINK_MODE=copy
24+
ENV UV_PROJECT_ENVIRONMENT=/usr/local
25+
ENV UV_PYTHON_DOWNLOADS=never
26+
ENV UV_NO_MANAGED_PYTHON=1
2527

26-
ENV PATH ${PATH}:/home/fastapi_template/.local/bin
28+
WORKDIR /src
29+
COPY . .
2730

28-
RUN pip install poetry==1.5.1
31+
ENV PATH="${PATH}:/usr/local/bin"
2932

30-
COPY . /src/
31-
RUN pip install .
33+
RUN --mount=type=cache,target=/root/.cache/uv \
34+
uv sync --locked --no-dev
3235

33-
USER root
34-
RUN rm -rfv /src
3536
RUN apk del curl
37+
38+
RUN chown -R fastapi_template:fastapi_template /projects /src /usr/local/lib/
39+
3640
USER fastapi_template
3741

3842
RUN git config --global user.name "Fastapi Template"
@@ -41,5 +45,4 @@ RUN git config --global user.email "fastapi-template@no-reply.com"
4145
VOLUME /projects
4246
WORKDIR /projects
4347

44-
ENTRYPOINT ["/home/fastapi_template/.local/bin/fastapi_template"]
45-
48+
ENTRYPOINT ["python", "-m", "fastapi_template"]

fastapi_template/template/{{cookiecutter.project_name}}/Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,16 @@ RUN apt-get update && apt-get install -y \
2424
ENV UV_COMPILE_BYTECODE=1
2525
ENV UV_LINK_MODE=copy
2626
ENV UV_PROJECT_ENVIRONMENT=/usr/local
27+
ENV UV_PYTHON_DOWNLOADS=never
28+
ENV UV_NO_MANAGED_PYTHON=1
2729

2830
WORKDIR /app/src
2931

3032
RUN --mount=from=uv,source=/uv,target=/bin/uv \
3133
--mount=type=cache,target=/root/.cache/uv \
3234
--mount=type=bind,source=uv.lock,target=uv.lock \
3335
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
34-
uv sync --locked --no-install-project --no-dev --managed-python
36+
uv sync --locked --no-install-project --no-dev
3537

3638
COPY . .
3739

fastapi_template/template/{{cookiecutter.project_name}}/pyproject.toml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ dependencies = [
1616
{%- if cookiecutter.orm == "sqlalchemy" %}
1717
"fastapi-users>=14.0.0,<15",
1818
"httpx-oauth>=0.16.1,<1",
19-
"fastapi-users-db-sqlalchemy>=6.0.1,<1",
19+
"fastapi-users-db-sqlalchemy>=7,<8",
2020
{%- endif %}
2121
{%- endif %}
2222
{%- if cookiecutter.orm == "ormar" %}
@@ -26,7 +26,7 @@ dependencies = [
2626
{%- endif %}
2727
"pydantic-settings>=2.7.0,<3",
2828
"yarl>=1.18.3,<2",
29-
"ujson>=5.10.0,6",
29+
"ujson>=5.10.0,<6",
3030
{%- if cookiecutter.orm == "piccolo" %}
3131
{%- if cookiecutter.db_info.name == "postgresql" %}
3232
"piccolo[postgres]>=1.22.0,<2",
@@ -40,7 +40,6 @@ dependencies = [
4040
"alembic>=1.14.0,<2",
4141
{%- endif %}
4242
{%- if cookiecutter.db_info.name == "postgresql" %}
43-
asyncpg = {version = "^0.30.0", extras = ["sa"]}
4443
"asyncpg>=0.31.0,<1",
4544
{%- elif cookiecutter.db_info.name == "sqlite" %}
4645
"aiosqlite>=0.20.0,<1",
@@ -102,7 +101,7 @@ asyncpg = {version = "^0.30.0", extras = ["sa"]}
102101
{%- endif %}
103102
{%- if cookiecutter.prometheus_enabled == "True" %}
104103
"prometheus-client>=0.21.1,<1",
105-
"prometheus-fastapi-instrumentator>=.0.0,<.1",
104+
"prometheus-fastapi-instrumentator>=7,<8",
106105
{%- endif %}
107106
{%- if cookiecutter.sentry_enabled == "True" %}
108107
"sentry-sdk>=2.19.2,<3",

0 commit comments

Comments
 (0)