Skip to content

Commit 882507b

Browse files
committed
Update Dockerfile and test, bump to 3.14
- Remove healthcheck; not needed and slow - Separate service startup - Do not check out repo, work from current directory - Move dev packages to dependency-groups - Add Python 3.14 - Upgrade pydantic to be compatible with 3.14
1 parent 351ebcb commit 882507b

File tree

6 files changed

+86
-148
lines changed

6 files changed

+86
-148
lines changed

.github/workflows/main.yml

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,36 @@ jobs:
99
test:
1010
runs-on: ubuntu-latest
1111
steps:
12-
- uses: actions/checkout@v4
13-
- uses: actions/setup-python@v5
14-
with:
15-
python-version: '3.12'
12+
- name: Install uv
13+
uses: astral-sh/setup-uv@v6
14+
1615
- name: create project
1716
run: |
18-
pip install django
19-
django-admin startproject \
17+
uv run --with django django-admin startproject \
2018
--template="https://github.com/lincolnloop/django-layout/zipball/$GITHUB_REF_NAME" \
2119
--extension=py,md,gitignore,yaml,json,toml \
2220
--name=Makefile,Dockerfile \
2321
--exclude=.github \
24-
testproj
22+
testproj .
23+
2524
- name: mock client build
2625
run: |
2726
mkdir -p client/dist
2827
touch client/dist/index.js
29-
working-directory: testproj
28+
29+
- name: build container
30+
run: docker compose build
31+
3032
- name: start services
31-
run: |
32-
docker compose up -d
33-
# wait for migrations to finish
34-
docker attach $(docker compose ps -q django-migrate)
33+
run: docker compose up -d db client
34+
35+
- name: run migrations
36+
run: docker compose run app python manage.py migrate --no-input
37+
38+
- name: start django
39+
run: docker compose up -d app
3540
timeout-minutes: 5
36-
working-directory: testproj
41+
3742
- name: verify services running
3843
run: |
3944
docker ps # show service status for debugging
@@ -46,20 +51,15 @@ jobs:
4651
curl -I --retry 10 --retry-all-errors --fail localhost:8000/static/index.js
4752
- name: run tests
4853
run: docker compose run --rm app make test
49-
working-directory: testproj
5054
- name: verify README.md
5155
run: docker compose run --rm --no-deps app cog --check README.md
52-
working-directory: testproj
5356
- name: lint code
5457
run: docker compose run --rm --no-deps app make lint
55-
working-directory: testproj
5658
- name: format code
5759
run: docker compose run --rm --no-deps app ruff format --check .
58-
working-directory: testproj
5960
- name: dump docker logs
6061
run: |
6162
set -x
6263
docker compose ps
6364
docker compose logs
64-
working-directory: testproj
6565
if: always()

Dockerfile

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,28 @@ FROM node:20-alpine AS build-node
44
WORKDIR /home/node/app/client
55
COPY client/package-lock.json client/package.json ./
66
RUN --mount=type=cache,target=/home/node/.npm \
7-
set -ex && npm install -g npm@latest && npm ci
7+
set -ex && npm install -g npm@latest && npm ci
88
COPY client/ ./
99
RUN npm run build
1010

1111

1212
# STAGE 2: BUILD PYTHON
13-
FROM python:3.12-bullseye AS build-python
13+
FROM python:3.14 as build-python
1414
WORKDIR /app
15-
RUN set -ex && pip install --root-user-action=ignore --no-cache-dir uv && uv venv
1615

16+
COPY --from=ghcr.io/astral-sh/uv:0.9.7 /uv /uvx /bin/
17+
ENV PYTHONPYCACHEPREFIX=/tmp/pycache
18+
ENV PYTHONUNBUFFERED=1
19+
ENV UV_COMPILE_BYTECODE=1
20+
ENV UV_LINK_MODE=copy
1721
ENV LC_ALL=C.UTF-8 LANG=C.UTF-8 \
18-
PATH=/app/.venv/bin:${PATH}
22+
PATH=/app/.venv/bin:${PATH}
1923

20-
# A blank string installs all extras. A non-existent extra will be ignored.
21-
ARG UV_EXTRA_DEPENDENCIES="null"
22-
COPY pyproject.toml uv.lock ./
23-
RUN --mount=type=cache,target=/root/.cache \
24-
uv sync --frozen --extra="${UV_EXTRA_DEPENDENCIES}"
24+
25+
RUN --mount=type=cache,target=/root/.cache/uv \
26+
--mount=type=bind,source=uv.lock,target=uv.lock \
27+
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
28+
uv sync --locked
2529

2630
COPY . ./
2731
COPY --from=build-node /home/node/app/client/dist ./client/dist

compose.yaml

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
services:
2-
32
client:
43
build:
54
context: .
@@ -16,11 +15,6 @@ services:
1615
volumes:
1716
- pgdata:/var/lib/postgresql/data/
1817
- .data/db_dumps:/db_dumps
19-
healthcheck:
20-
test: pg_isready -U postgres -d {{ project_name }}
21-
interval: 5s
22-
timeout: 10s
23-
retries: 120
2418
environment:
2519
- POSTGRES_DB={{ project_name }}
2620
- POSTGRES_PASSWORD=postgres
@@ -39,8 +33,7 @@ services:
3933
- SECRET_KEY=not-secret
4034
restart: on-failure
4135
depends_on:
42-
db:
43-
condition: service_healthy
36+
- db
4437
command: python manage.py runserver 0.0.0.0:8000
4538
ports:
4639
- ${PORT:-8000}:8000
@@ -52,14 +45,6 @@ services:
5245
- /app/{{ project_name }}.egg-info
5346
- client:/app/client/dist
5447

55-
django-migrate:
56-
<<: *COMMON
57-
command: python manage.py migrate --noinput
58-
volumes:
59-
- .:/app
60-
- /app/.venv
61-
- /app/{{ project_name }}.egg-info
62-
6348
volumes:
6449
client:
6550
pgdata:

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
55
[project]
66
name = "django-layout"
77
version = "4.0"
8-
requires-python = ">=3.12"
8+
requires-python = "==3.14.0"
99
dependencies = [
1010
"django==5.1.*",
1111
"dj-database-url",
@@ -20,7 +20,7 @@ dependencies = [
2020
"wsgi-basic-auth",
2121
]
2222

23-
[project.optional-dependencies]
23+
[dependency-groups]
2424
dev = [
2525
"cogapp",
2626
"django-stubs",

renovate.json

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
{
22
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
3-
"extends": ["helpers:pinGitHubActionDigests"],
3+
"extends": [
4+
"helpers:pinGitHubActionDigests"
5+
],
46
"automerge": true,
57
"automergeType": "pr",
68
"lockFileMaintenance": {
@@ -15,11 +17,4 @@
1517
"enabled": true
1618
},
1719
"rangeStrategy": "pin",
18-
"packageRules": [
19-
{
20-
"matchManagers": ["pep621"],
21-
"matchDepNames": ["python"],
22-
"enabled": false
23-
}
24-
]
2520
}

0 commit comments

Comments
 (0)