Skip to content
This repository has been archived by the owner on Nov 21, 2024. It is now read-only.

Commit

Permalink
Merge pull request #358 from communitiesuk/uv-requirements
Browse files Browse the repository at this point in the history
Migrate app to use `uv` for dependencies
  • Loading branch information
samuelhwilliams authored Nov 13, 2024
2 parents f550016 + 7fec090 commit b4cb41c
Show file tree
Hide file tree
Showing 7 changed files with 1,762 additions and 571 deletions.
21 changes: 16 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
FROM python:3.10-bullseye

WORKDIR /app
COPY requirements-dev.txt requirements-dev.txt
RUN pip --no-cache-dir install --ignore-installed distlib -r requirements-dev.txt
RUN pip install gunicorn
RUN pip install uvicorn
RUN apt-get update && apt-get install -y postgresql-client

COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/

# Install the project's dependencies using the lockfile and settings
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

# Then, add the rest of the project source code and install it
# Installing separately from its dependencies allows optimal layer caching
COPY . .
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --frozen

# Place executables in the environment at the front of the path
ENV PATH="/app/.venv/bin:$PATH"
EXPOSE 8080

CMD ["gunicorn", "--worker-class", "uvicorn.workers.UvicornWorker", "wsgi:app", "-b", "0.0.0.0:8080"]
2 changes: 1 addition & 1 deletion db/migrations/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def process_revision_directives(context, revision, directives):
connection=connection,
target_metadata=get_metadata(),
process_revision_directives=process_revision_directives,
**current_app.extensions["migrate"].configure_args
**current_app.extensions["migrate"].configure_args,
)

with context.begin_transaction():
Expand Down
44 changes: 43 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,33 @@
[package]
[project]
name = "funding-service-design-fund-store"
version = "0.1.1"
description = "The funding service design fund store for the DLUHC."
authors = ["Version One", "HM Government, Department of Levelling Up, Housing and Communities"]
license = "MIT License"

requires-python = ">=3.10, <3.11"
dependencies = [
"airium>=0.2.6",
"bs4>=0.0.2",
"connexion[flask,swagger-ui,uvicorn]>=3.1.0",
"flask-json==0.4.0",
"flask-migrate==4.0.7",
"flask-sqlalchemy==3.1.1",
"flask==3.0.3",
"funding-service-design-utils>=5.0.8,<6.0.0",
"marshmallow-sqlalchemy==1.0.0",
"openapi-spec-validator>=0.7.1",
"prance>=23.6.21.0",
"psycopg2-binary==2.9.9",
"pytest-html>=3.2.0",
"pytest-mock==3.14.0",
"sqlalchemy-json==0.7.0",
"sqlalchemy-utils==0.41.2",
"sqlalchemy[mypy]>=2.0.30",
"swagger-ui-bundle==1.1.0",
"uvicorn==0.30.1",
]

[tool.black]
line-length = 120

Expand All @@ -17,3 +40,22 @@ exclude = ['config/fund_loader_config/FAB/*']
[tool.isort]
profile = "black"
force_single_line = "true"

[tool.uv]

[dependency-groups]
dev = [
"asserts==0.11.1",
"black>=24.4.2",
"colored>=2.2.4",
"debugpy>=1.8.1",
"deepdiff>=7.0.1",
"flake8-pyproject>=1.2.3",
"invoke>=2.2.0",
"json2html==1.3.0",
"pre-commit~=4.0.0",
"pytest>=8.2.2",
"pytest-env>=1.1.3",
"pytest-flask>=1.3.0",
"pytest-mock==3.14.0",
]
15 changes: 0 additions & 15 deletions requirements-dev.in

This file was deleted.

Loading

0 comments on commit b4cb41c

Please sign in to comment.