🧑💻 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"
|
python-version: "3.10"
|
||||||
- name: Install uv
|
- name: Install uv
|
||||||
uses: astral-sh/setup-uv@v7
|
uses: astral-sh/setup-uv@v7
|
||||||
with:
|
|
||||||
version: "0.4.15"
|
|
||||||
enable-cache: true
|
|
||||||
- run: docker compose down -v --remove-orphans
|
- run: docker compose down -v --remove-orphans
|
||||||
- run: docker compose up -d db mailcatcher
|
- run: docker compose up -d db mailcatcher
|
||||||
- name: Migrate DB
|
- name: Migrate DB
|
||||||
|
|||||||
@@ -2,16 +2,10 @@ FROM python:3.10
|
|||||||
|
|
||||||
ENV PYTHONUNBUFFERED=1
|
ENV PYTHONUNBUFFERED=1
|
||||||
|
|
||||||
WORKDIR /app/
|
|
||||||
|
|
||||||
# Install uv
|
# Install uv
|
||||||
# Ref: https://docs.astral.sh/uv/guides/integration/docker/#installing-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/
|
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
|
# Compile bytecode
|
||||||
# Ref: https://docs.astral.sh/uv/guides/integration/docker/#compiling-bytecode
|
# Ref: https://docs.astral.sh/uv/guides/integration/docker/#compiling-bytecode
|
||||||
ENV UV_COMPILE_BYTECODE=1
|
ENV UV_COMPILE_BYTECODE=1
|
||||||
@@ -20,25 +14,32 @@ ENV UV_COMPILE_BYTECODE=1
|
|||||||
# Ref: https://docs.astral.sh/uv/guides/integration/docker/#caching
|
# Ref: https://docs.astral.sh/uv/guides/integration/docker/#caching
|
||||||
ENV UV_LINK_MODE=copy
|
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
|
# Install dependencies
|
||||||
# Ref: https://docs.astral.sh/uv/guides/integration/docker/#intermediate-layers
|
# Ref: https://docs.astral.sh/uv/guides/integration/docker/#intermediate-layers
|
||||||
RUN --mount=type=cache,target=/root/.cache/uv \
|
RUN --mount=type=cache,target=/root/.cache/uv \
|
||||||
--mount=type=bind,source=uv.lock,target=uv.lock \
|
--mount=type=bind,source=uv.lock,target=uv.lock \
|
||||||
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
|
--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 ./backend/app /app/backend/app
|
||||||
|
|
||||||
COPY ./app /app/app
|
|
||||||
COPY ./tests /app/tests
|
|
||||||
|
|
||||||
# Sync the project
|
# Sync the project
|
||||||
# Ref: https://docs.astral.sh/uv/guides/integration/docker/#intermediate-layers
|
# Ref: https://docs.astral.sh/uv/guides/integration/docker/#intermediate-layers
|
||||||
RUN --mount=type=cache,target=/root/.cache/uv \
|
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"]
|
CMD ["fastapi", "run", "--workers", "4", "app/main.py"]
|
||||||
|
|||||||
@@ -23,8 +23,8 @@ dependencies = [
|
|||||||
"pyjwt<3.0.0,>=2.8.0",
|
"pyjwt<3.0.0,>=2.8.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[tool.uv]
|
[dependency-groups]
|
||||||
dev-dependencies = [
|
dev = [
|
||||||
"pytest<8.0.0,>=7.4.3",
|
"pytest<8.0.0,>=7.4.3",
|
||||||
"mypy<2.0.0,>=1.8.0",
|
"mypy<2.0.0,>=1.8.0",
|
||||||
"ruff<1.0.0,>=0.2.2",
|
"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:
|
ports:
|
||||||
- "8000:8000"
|
- "8000:8000"
|
||||||
build:
|
build:
|
||||||
context: ./backend
|
context: .
|
||||||
|
dockerfile: backend/Dockerfile
|
||||||
# command: sleep infinity # Infinite loop to keep container alive doing nothing
|
# command: sleep infinity # Infinite loop to keep container alive doing nothing
|
||||||
command:
|
command:
|
||||||
- fastapi
|
- fastapi
|
||||||
@@ -71,7 +72,7 @@ services:
|
|||||||
watch:
|
watch:
|
||||||
- path: ./backend
|
- path: ./backend
|
||||||
action: sync
|
action: sync
|
||||||
target: /app
|
target: /app/backend
|
||||||
ignore:
|
ignore:
|
||||||
- ./backend/.venv
|
- ./backend/.venv
|
||||||
- .venv
|
- .venv
|
||||||
@@ -79,7 +80,7 @@ services:
|
|||||||
action: rebuild
|
action: rebuild
|
||||||
# TODO: remove once coverage is done locally
|
# TODO: remove once coverage is done locally
|
||||||
volumes:
|
volumes:
|
||||||
- ./backend/htmlcov:/app/htmlcov
|
- ./backend/htmlcov:/app/backend/htmlcov
|
||||||
environment:
|
environment:
|
||||||
SMTP_HOST: "mailcatcher"
|
SMTP_HOST: "mailcatcher"
|
||||||
SMTP_PORT: "1025"
|
SMTP_PORT: "1025"
|
||||||
|
|||||||
@@ -45,7 +45,8 @@ services:
|
|||||||
prestart:
|
prestart:
|
||||||
image: '${DOCKER_IMAGE_BACKEND?Variable not set}:${TAG-latest}'
|
image: '${DOCKER_IMAGE_BACKEND?Variable not set}:${TAG-latest}'
|
||||||
build:
|
build:
|
||||||
context: ./backend
|
context: .
|
||||||
|
dockerfile: backend/Dockerfile
|
||||||
networks:
|
networks:
|
||||||
- traefik-public
|
- traefik-public
|
||||||
- default
|
- default
|
||||||
@@ -115,7 +116,8 @@ services:
|
|||||||
retries: 5
|
retries: 5
|
||||||
|
|
||||||
build:
|
build:
|
||||||
context: ./backend
|
context: .
|
||||||
|
dockerfile: backend/Dockerfile
|
||||||
labels:
|
labels:
|
||||||
- traefik.enable=true
|
- traefik.enable=true
|
||||||
- traefik.docker.network=traefik-public
|
- traefik.docker.network=traefik-public
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ export const Body_login_login_access_tokenSchema = {
|
|||||||
anyOf: [
|
anyOf: [
|
||||||
{
|
{
|
||||||
type: 'string',
|
type: 'string',
|
||||||
pattern: 'password'
|
pattern: '^password$'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'null'
|
type: 'null'
|
||||||
@@ -20,6 +20,7 @@ export const Body_login_login_access_tokenSchema = {
|
|||||||
},
|
},
|
||||||
password: {
|
password: {
|
||||||
type: 'string',
|
type: 'string',
|
||||||
|
format: 'password',
|
||||||
title: 'Password'
|
title: 'Password'
|
||||||
},
|
},
|
||||||
scope: {
|
scope: {
|
||||||
@@ -47,6 +48,7 @@ export const Body_login_login_access_tokenSchema = {
|
|||||||
type: 'null'
|
type: 'null'
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
format: 'password',
|
||||||
title: 'Client Secret'
|
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