Skip to content

Commit 83c4660

Browse files
committed
Improve tooling
1 parent 2ca6f5c commit 83c4660

File tree

7 files changed

+68
-65
lines changed

7 files changed

+68
-65
lines changed

.dockerignore

Lines changed: 10 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,10 @@
1-
# Venv
2-
.venv/
3-
4-
# Git
5-
.git/
6-
.gitignore
7-
.gitattributes
8-
9-
# Python Cache
10-
__pycache__/
11-
*.py[cod]
12-
*$py.class
13-
.mypy_cache/
14-
.ruff_cache/
15-
16-
# IDE Specific
17-
.idea/
18-
.vscode/
19-
20-
# Test artifacts
21-
.coverage
22-
htmlcov/
23-
24-
# Documentation and non-essential files
25-
docs/
26-
scripts/
27-
LICENSE
28-
logo.jpg
29-
30-
# Local environment
31-
.env*
1+
# Ignore everything
2+
**
3+
4+
# Except
5+
!pyproject.toml
6+
!uv.lock
7+
!README.md
8+
!config/**
9+
!src/**
10+
!alembic.ini

.github/workflows/ci.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,18 @@ jobs:
1818
uses: astral-sh/setup-uv@v6
1919

2020
- name: Install dependencies
21-
run: uv pip install -e '.[dev,test]' --system
21+
run: uv sync --locked --group dev
2222

2323
- name: Check code
24-
run: make code.check
24+
run: uv run make code.check
2525

2626
- name: Test Docker Compose setup
27+
env:
28+
APP_ENV: local
2729
run: |
28-
export APP_ENV=local
29-
python config/toml_config_manager.py
30+
uv run config/toml_config_manager.py
3031
cd config/local
31-
export COMPOSE_ENV_FILES=.env.local
32-
docker compose up -d --build
32+
docker compose --env-file .env.local up -d --build
3333
3434
- name: Verify Application Health
3535
run: |

README.md

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -620,19 +620,28 @@ make env # should print APP_ENV=local
620620
make dotenv # should tell you where .env.local was generated
621621
```
622622

623-
4. Set up virtual environment
623+
4. Install `uv`
624624

625625
```shell
626626
# sudo apt update
627627
# sudo apt install pipx
628628
# pipx ensurepath
629629
# pipx install uv
630-
# uv python install 3.13
631-
uv v
632-
source .venv/bin/activate
633-
# .venv\Scripts\activate # Windows
634630
# https://docs.astral.sh/uv/getting-started/installation/#shell-autocompletion
635-
uv pip install -e '.[dev,test]'
631+
# uv python install 3.13 # To install Python
632+
```
633+
634+
5. Set up virtual environment
635+
636+
```shell
637+
uv sync --group dev
638+
source .venv/bin/activate
639+
640+
# Alternatively,
641+
# uv v
642+
# source .venv/bin/activate # on Unix
643+
# .venv\Scripts\activate # on Windows
644+
# uv pip install -e . --group dev
636645
```
637646

638647
Don't forget to tell your IDE where the interpreter is located.
@@ -644,7 +653,7 @@ Install pre-commit hooks:
644653
pre-commit install
645654
```
646655

647-
5. Launch
656+
6. Launch
648657

649658
- To run only the database in Docker and use the app locally, use the following command:
650659

@@ -670,7 +679,7 @@ pre-commit install
670679
671680
In this case, migrations will be applied automatically at startup.
672681
673-
6. Shutdown
682+
7. Shutdown
674683
675684
- To stop the containers, use:
676685
```shell

config/local/Dockerfile

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,24 @@ FROM ghcr.io/astral-sh/uv:python3.13-bookworm-slim AS builder
22
WORKDIR /app
33
ENV UV_COMPILE_BYTECODE=1 \
44
UV_LINK_MODE=copy
5-
COPY pyproject.toml README.md ./
6-
COPY src/ ./src/
5+
COPY pyproject.toml uv.lock ./
76
RUN --mount=type=cache,target=/root/.cache/uv \
8-
uv pip install --system --target /app/dependencies .
7+
uv sync --locked --no-dev --no-install-project
98
COPY . ./
9+
RUN --mount=type=cache,target=/root/.cache/uv \
10+
uv sync --locked --no-dev
1011

1112
FROM python:3.13-slim-bookworm AS final
1213
ARG APP_UID=10001
1314
ARG APP_GID=10001
1415
RUN groupadd -g ${APP_GID} appgroup && \
1516
useradd -u ${APP_UID} -g ${APP_GID} -s /usr/sbin/nologin -M appuser
1617
WORKDIR /app
17-
ENV PYTHONDONTWRITEBYTECODE=1 \
18-
PYTHONUNBUFFERED=1 \
19-
PYTHONPATH="/app/dependencies" \
20-
PATH="/app/dependencies/bin:$PATH"
18+
ENV VIRTUAL_ENV="/app/.venv" \
19+
PATH="/app/.venv/bin:$PATH" \
20+
PYTHONDONTWRITEBYTECODE=1 \
21+
PYTHONUNBUFFERED=1
2122
COPY --from=builder --chown=${APP_UID}:${APP_GID} /app/ ./
2223
USER appuser
2324
EXPOSE 8888
24-
CMD ["uvicorn", "app.run:make_app", "--host", "0.0.0.0", "--port", "8888", "--loop", "uvloop"]
25+
CMD ["uvicorn", "app.run:make_app", "--factory", "--host", "0.0.0.0", "--port", "8888", "--loop", "uvloop"]

config/local/docker-compose.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ services:
3838
echo 'Running alembic migrations...' &&
3939
alembic upgrade head &&
4040
echo 'Starting Uvicorn...' &&
41-
uvicorn app.run:make_app --host ${UVICORN_HOST} --port ${UVICORN_PORT} --loop uvloop
41+
uvicorn app.run:make_app --factory --host ${UVICORN_HOST} --port ${UVICORN_PORT} --loop uvloop
4242
"
4343
4444
volumes:

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,13 @@ dependencies = [
3434
"uvloop==0.21.0",
3535
]
3636

37-
[project.optional-dependencies]
37+
[dependency-groups]
3838
dev = [
3939
"mypy==1.17.0",
4040
"pre-commit==4.2.0",
4141
"ruff==0.12.5",
4242
"slotscheck==0.19.1",
43+
{ include-group = "test" },
4344
]
4445
test = [
4546
"coverage==7.10.0",

uv.lock

Lines changed: 23 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)