🧑‍💻 Implement uv workspaces (#2090)

This commit is contained in:
Alejandra
2026-01-20 19:19:07 +01:00
committed by GitHub
parent fcad8f8270
commit 3a5611aa7f
9 changed files with 2073 additions and 1626 deletions

View File

@@ -21,9 +21,6 @@ jobs:
python-version: "3.10"
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
version: "0.4.15"
enable-cache: true
- run: docker compose down -v --remove-orphans
- run: docker compose up -d db mailcatcher
- name: Migrate DB

View File

@@ -2,16 +2,10 @@ FROM python:3.10
ENV PYTHONUNBUFFERED=1
WORKDIR /app/
# Install uv
# Ref: https://docs.astral.sh/uv/guides/integration/docker/#installing-uv
COPY --from=ghcr.io/astral-sh/uv:0.5.11 /uv /uvx /bin/
# Place executables in the environment at the front of the path
# Ref: https://docs.astral.sh/uv/guides/integration/docker/#using-the-environment
ENV PATH="/app/.venv/bin:$PATH"
# Compile bytecode
# Ref: https://docs.astral.sh/uv/guides/integration/docker/#compiling-bytecode
ENV UV_COMPILE_BYTECODE=1
@@ -20,25 +14,32 @@ ENV UV_COMPILE_BYTECODE=1
# Ref: https://docs.astral.sh/uv/guides/integration/docker/#caching
ENV UV_LINK_MODE=copy
WORKDIR /app/
# Place executables in the environment at the front of the path
# Ref: https://docs.astral.sh/uv/guides/integration/docker/#using-the-environment
ENV PATH="/app/.venv/bin:$PATH"
# Install dependencies
# Ref: https://docs.astral.sh/uv/guides/integration/docker/#intermediate-layers
RUN --mount=type=cache,target=/root/.cache/uv \
--mount=type=bind,source=uv.lock,target=uv.lock \
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
uv sync --frozen --no-install-project
uv sync --frozen --no-install-workspace --package app
ENV PYTHONPATH=/app
COPY ./backend/scripts /app/backend/scripts
COPY ./scripts /app/scripts
COPY ./backend/pyproject.toml ./backend/alembic.ini /app/backend/
COPY ./pyproject.toml ./uv.lock ./alembic.ini /app/
COPY ./app /app/app
COPY ./tests /app/tests
COPY ./backend/app /app/backend/app
# Sync the project
# Ref: https://docs.astral.sh/uv/guides/integration/docker/#intermediate-layers
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync
--mount=type=bind,source=uv.lock,target=uv.lock \
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
uv sync --frozen --package app
WORKDIR /app/backend/
CMD ["fastapi", "run", "--workers", "4", "app/main.py"]

View File

@@ -23,8 +23,8 @@ dependencies = [
"pyjwt<3.0.0,>=2.8.0",
]
[tool.uv]
dev-dependencies = [
[dependency-groups]
dev = [
"pytest<8.0.0,>=7.4.3",
"mypy<2.0.0,>=1.8.0",
"ruff<1.0.0,>=0.2.2",

1601
backend/uv.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -60,7 +60,8 @@ services:
ports:
- "8000:8000"
build:
context: ./backend
context: .
dockerfile: backend/Dockerfile
# command: sleep infinity # Infinite loop to keep container alive doing nothing
command:
- fastapi
@@ -71,7 +72,7 @@ services:
watch:
- path: ./backend
action: sync
target: /app
target: /app/backend
ignore:
- ./backend/.venv
- .venv
@@ -79,7 +80,7 @@ services:
action: rebuild
# TODO: remove once coverage is done locally
volumes:
- ./backend/htmlcov:/app/htmlcov
- ./backend/htmlcov:/app/backend/htmlcov
environment:
SMTP_HOST: "mailcatcher"
SMTP_PORT: "1025"

View File

@@ -45,7 +45,8 @@ services:
prestart:
image: '${DOCKER_IMAGE_BACKEND?Variable not set}:${TAG-latest}'
build:
context: ./backend
context: .
dockerfile: backend/Dockerfile
networks:
- traefik-public
- default
@@ -115,7 +116,8 @@ services:
retries: 5
build:
context: ./backend
context: .
dockerfile: backend/Dockerfile
labels:
- traefik.enable=true
- traefik.docker.network=traefik-public

View File

@@ -6,7 +6,7 @@ export const Body_login_login_access_tokenSchema = {
anyOf: [
{
type: 'string',
pattern: 'password'
pattern: '^password$'
},
{
type: 'null'
@@ -20,6 +20,7 @@ export const Body_login_login_access_tokenSchema = {
},
password: {
type: 'string',
format: 'password',
title: 'Password'
},
scope: {
@@ -47,6 +48,7 @@ export const Body_login_login_access_tokenSchema = {
type: 'null'
}
],
format: 'password',
title: 'Client Secret'
}
},

2
pyproject.toml Normal file
View File

@@ -0,0 +1,2 @@
[tool.uv.workspace]
members = ["backend"]

2043
uv.lock generated Normal file

File diff suppressed because it is too large Load Diff