🧑💻 Implement uv workspaces (#2090)
This commit is contained in:
3
.github/workflows/test-backend.yml
vendored
3
.github/workflows/test-backend.yml
vendored
@@ -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
|
||||
|
||||
@@ -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"]
|
||||
|
||||
@@ -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
1601
backend/uv.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -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"
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
2
pyproject.toml
Normal file
@@ -0,0 +1,2 @@
|
||||
[tool.uv.workspace]
|
||||
members = ["backend"]
|
||||
Reference in New Issue
Block a user