Skip to content

Commit 11eaba8

Browse files
author
Janek Mangold
committed
feat: update CI configuration and Docker setup for improved staging deployment and testing
1 parent 6b5d6df commit 11eaba8

File tree

5 files changed

+33
-10
lines changed

5 files changed

+33
-10
lines changed

django/{{ cookiecutter.project_slug }}/.gitlab-ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ variables:
1212
POSTGRES_DB: {{ cookiecutter.project_slug }}
1313
POSTGRES_USER: {{ cookiecutter.project_slug }}
1414
POSTGRES_PASSWORD: {{ cookiecutter.project_slug }}
15+
UV_LINK_MODE: copy
1516

1617
workflow:
1718
rules:

django/{{ cookiecutter.project_slug }}/.gitlab/Dockerfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,7 @@ COPY . .
1414

1515
FROM base as app
1616

17-
RUN uv run --no-dev --group production manage.py collectstatic --no-input
17+
ENV UV_NO_DEV 1
18+
RUN uv sync --group production
19+
ENV UV_NO_SYNC 1
20+
RUN uv run manage.py collectstatic --no-input

django/{{ cookiecutter.project_slug }}/.gitlab/ci/lint.gitlab-ci.yml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,18 @@ pre-commit:
66
image: astral/uv:python{{ cookiecutter.python_version }}-bookworm
77
variables:
88
PRE_COMMIT_HOME: ${CI_PROJECT_DIR}/.cache/pre-commit
9+
UV_CACHE_DIR: .uv-cache
910
cache:
10-
paths:
11-
- ${PRE_COMMIT_HOME}
12-
- ${UV_CACHE_DIR}
13-
key:
14-
files:
15-
- uv.lock
16-
- .pre-commit-config.yaml
11+
- key:
12+
files:
13+
- uv.lock
14+
paths:
15+
- ${UV_CACHE_DIR}
16+
- key:
17+
files:
18+
- .pre-commit-config.yaml
19+
paths:
20+
- ${PRE_COMMIT_HOME}
1721
script:
1822
- uvx pre-commit run --show-diff-on-failure --color=always --all-files
1923
after_script:

django/{{ cookiecutter.project_slug }}/.gitlab/ci/test.gitlab-ci.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,18 @@ django-test:
1212
POSTGRES_PORT: "5432"
1313
script:
1414
- uv run manage.py test
15+
16+
deploy-check:
17+
stage: test
18+
interruptible: true
19+
allow_failure: true
20+
image: orbisk/django-test:3.12
21+
extends:
22+
- .size:medium
23+
variables:
24+
DJANGO_SETTINGS_MODULE: "{{ cookiecutter.project_slug }}.settings.staging"
25+
script:
26+
- uv run manage.py check --deploy --fail-level DEBUG --force-color
27+
rules:
28+
- if: $CI_COMMIT_REF_PROTECTED
29+
allow_failure: false

django/{{ cookiecutter.project_slug }}/.gitlab/docker-compose.staging.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ services:
1515
depends_on:
1616
postgres:
1717
condition: service_healthy
18-
command: [ "uv", "run","--no-dev", "--group", "production", "manage.py", "migrate" ]
18+
command: [ "uv", "run", "manage.py", "migrate" ]
1919

2020
app:
2121
extends:
@@ -25,7 +25,7 @@ services:
2525
dockerfile: .gitlab/Dockerfile
2626
target: app
2727
restart: unless-stopped
28-
command: ["uv", "run","--no-dev", "--group", "production", "gunicorn", "-b", ":8000", "--workers=3", "--enable-stdio-inheritance", "{{ cookiecutter.project_slug }}.wsgi:application"]
28+
command: ["uv", "run", "gunicorn", "-b", ":8000", "--workers=3", "--enable-stdio-inheritance", "{{ cookiecutter.project_slug }}.wsgi:application"]
2929
expose:
3030
- 8000
3131
postgres:

0 commit comments

Comments
 (0)