Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions .github/workflows/linting-and-checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,16 @@ jobs:
- name: "Setup: checkout repository"
uses: actions/checkout@v4

- name: "Setup: install poetry"
run: pipx install poetry

- name: "Setup: add python"
uses: actions/setup-python@v5
- name: "Setup: install uv"
uses: astral-sh/setup-uv@v5
with:
python-version: "3.12"
cache: "poetry"
enable-cache: true

- name: "Setup: install dependencies"
run: poetry install
run: uv sync --locked --dev

- name: "Run: mypy"
run: poetry run mypy src
run: uv run mypy src

typescript-compile:
runs-on: ubuntu-latest
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ jobs:
run: |
docker pull $API_IMAGE
docker build --target development --tag api-development ./api # TODO: --cache-from $API_IMAGE

- name: Pytest Unit tests
run: docker compose -f docker-compose.yml -f docker-compose.ci.yml run --rm api pytest --unit

Expand All @@ -44,7 +43,6 @@ jobs:
run: |
docker pull $API_IMAGE
docker build --target development --tag api-development ./api # TODO: --cache-from $API_IMAGE

- name: BDD Integration tests
if: ${{ false }} # disable for now
run: docker compose -f docker-compose.yml -f docker-compose.ci.yml run api behave
Expand All @@ -54,6 +52,7 @@ jobs:

web-tests:
runs-on: ubuntu-latest
if: ${{ false }} # disable for now as they do not currently work
steps:
- uses: actions/checkout@v4

Expand Down
47 changes: 28 additions & 19 deletions api/Dockerfile
Comment thread
einarwar marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -1,26 +1,35 @@
FROM --platform=linux/amd64 python:3.13-slim AS base
WORKDIR /code
CMD ["/code/src/init.sh", "api"]
EXPOSE 5000
# First, build the application in the `/app` directory
FROM --platform=linux/amd64 ghcr.io/astral-sh/uv:bookworm-slim AS uv-base
ENV UV_COMPILE_BYTECODE=1
ENV UV_LINK_MODE=copy

# Configure the Python directory so it is consistent
ENV UV_PYTHON_INSTALL_DIR=/python

# Only use the managed Python version
ENV UV_PYTHON_PREFERENCE=only-managed

ENV PYTHONUNBUFFERED=1
ENV PYTHONPATH=/code
RUN uv python install 3.13

RUN pip install --upgrade pip && \
pip install poetry && \
poetry config virtualenvs.create false
FROM uv-base AS base
# Install Python before the project for caching

WORKDIR /app
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 --locked --no-install-project --no-dev
COPY . /app

# Place executables in the environment at the front of the path
ENV PATH="/app/.venv/bin:$PATH"
WORKDIR /app/src
EXPOSE 5000
CMD ["/app/src/init.sh", "api"]

COPY pyproject.toml pyproject.toml
COPY poetry.lock poetry.lock

FROM base AS development
RUN poetry install
WORKDIR /code/src
COPY src .
USER 1000
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --locked --dev

FROM base AS prod
RUN poetry install --without dev
WORKDIR /code/src
COPY src .
USER 1000
2,416 changes: 0 additions & 2,416 deletions api/poetry.lock

This file was deleted.

56 changes: 26 additions & 30 deletions api/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,36 +1,32 @@
[tool.poetry]
[project]
name = "api"
version = "1.4.0" # x-release-please-version
version = "1.4.0"
description = "API for Template Fastapi React"
authors = []
license = ""
package-mode = false

[tool.poetry.dependencies]
cachetools = "^5.5.2"
python = "^3.12"
fastapi = { extras = ["standard"], version = "^0.115.8" }
pyjwt = "^2.8.0"
pymongo = "4.11.1"
certifi = "^2025.1.31"
httpx = "^0.28"
pydantic = "^2.10"
pydantic-settings = "^2.8"
pydantic-extra-types = "^2.10"
azure-monitor-opentelemetry = "^1.6.5"
opentelemetry-instrumentation-fastapi = "^0.51b0"
cryptography = "^44.0.1"
requires-python = ">=3.13"
dependencies = [
"azure-monitor-opentelemetry>=1.6.5",
"cachetools>=5.5.2",
"certifi>=2025.4.26",
"cryptography>=44.0.1",
"fastapi[standard]>=0.115.8",
"httpx>=0.28",
"opentelemetry-instrumentation-fastapi>=0.51b0",
"pydantic>=2.10",
"pydantic-extra-types>=2.10",
"pydantic-settings>=2.8",
"pyjwt>=2.8.0",
"pymongo>=4.11.1",
]

[tool.poetry.group.dev.dependencies]
pre-commit = ">=3"
pytest = "^8.3"
mongomock = "^4.1.2"
mypy = "^1.14.1"
types-cachetools = "^5.5.0.20240820"
[dependency-groups]
dev = [
"mongomock>=4.1.2",
"mypy>=1.14.1",
"pre-commit>=3",
"pytest>=8.3.0",
"types-cachetools>=5.5.0.20240820",
]

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

[tool.mypy]
plugins = ["pydantic.mypy"]
Expand All @@ -39,7 +35,7 @@ exclude = ["/tests/"]
ignore_missing_imports = true
namespace_packages = true
explicit_package_bases = true
allow_subclassing_any = true
disallow_subclassing_any = false

[tool.ruff]
src = ["src"]
Expand Down
Loading