Skip to content

Commit db6a9b2

Browse files
committed
feat: improve staging configuration, add production group to uv, update README.md
1 parent 3d32b40 commit db6a9b2

5 files changed

Lines changed: 36 additions & 26 deletions

File tree

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,8 @@ ENV PYTHONDONTWRITEBYTECODE 1
1010
ENV PYTHONUNBUFFERED 1
1111
ENV DEBIAN_FRONTEND noninteractive
1212

13-
RUN uv sync
14-
1513
COPY . .
1614

1715
FROM base as app
1816

19-
RUN uv run manage.py collectstatic --no-input
17+
RUN uv run --no-dev --group production manage.py collectstatic --no-input

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ services:
1111
- POSTGRES_DB
1212
- POSTGRES_USER
1313
- POSTGRES_PASSWORD
14-
- POSTGRES_HOST # TODO: Set this to the service name of your PostgreSQL container
14+
- POSTGRES_HOST={{ cookiecutter.project_slug }}-postgres
1515
depends_on:
1616
postgres:
1717
condition: service_healthy
18-
command: [ "uv", "run", "manage.py", "migrate" ]
18+
command: [ "uv", "run","--no-dev", "--group", "production", "manage.py", "migrate" ]
1919

2020
app:
2121
extends:
@@ -25,10 +25,14 @@ services:
2525
dockerfile: .gitlab/Dockerfile
2626
target: app
2727
restart: unless-stopped
28-
command: ["uv", "run", "gunicorn", "-b", ":8000", "--workers=3", "--enable-stdio-inheritance", "{{ cookiecutter.project_slug }}.wsgi:application"]
28+
command: ["uv", "run","--no-dev", "--group", "production", "gunicorn", "-b", ":8000", "--workers=3", "--enable-stdio-inheritance", "{{ cookiecutter.project_slug }}.wsgi:application"]
2929
expose:
3030
- 8000
3131
postgres:
32+
networks:
33+
default:
34+
aliases:
35+
- {{ cookiecutter.project_slug }}-postgres
3236
image: postgres:{{ cookiecutter.postgresql_version }}
3337
restart: unless-stopped
3438
volumes:

django/{{ cookiecutter.project_slug }}/README.md

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
# {{ cookiecutter.project_name }}
1+
# {{ cookiecutter.project_name }} ({{ cookiecutter.customer }})
2+
23

34
## Tech stack
45

@@ -7,40 +8,45 @@
78
- PostgreSQL {{ cookiecutter.postgresql_version }}
89
- Django
910

11+
12+
**------------------- BEGIN DELETE SECTION --------------------**
13+
1014
## Get started after cookiecutter
1115

12-
1. Adjust the code as you need
13-
2. Resolve the remaining TODOs in the code
14-
3. Create a remote git repository
15-
4. Initialize git in the project
16+
1. Create a new remote git repository [here](https://singular-code.de/projects/new)
17+
1. Create the following CI/CD variables (under Settings > CI/CD > Variables > Project variables):
18+
- `DJANGO_SECRET_KEY`
19+
- Visibility: `Masked`
20+
- Protect variable: `yes`
21+
- Expand variable reference: `no`
22+
- Key: `DJANGO_SECRET_KEY`
23+
- Value:
24+
```shell
25+
python -c "import secrets; print(secrets.token_urlsafe(50))"
26+
```
27+
2. Initialize git in the project
1628

1729
```bash
18-
git init -b main
30+
git init --initial-branch=main
1931
```
20-
5. Enable pre-commit hooks:
32+
3. Enable pre-commit hooks:
2133

2234
```bash
2335
pre-commit install
2436
```
2537

26-
6. Add and commit the initial code:
38+
4. Delete this section
39+
40+
5. Create an initial commit and push to the remote repository:
2741

2842
```bash
2943
git add .
3044
git commit -m "Initial commit"
3145
git remote add origin <your-repo-url>
32-
git push origin main
46+
git push --set-upstream origin main
3347
```
3448

35-
5. Go to the remote git repository and create a CI/CD variable (under Settings > CI/CD > Variables > Project variables):
36-
37-
- `DJANGO_SECRET_KEY`
38-
- Visibility: `Masked`
39-
- Protect variable: `yes`
40-
- Expand variable reference: `no`
41-
- Key: `DJANGO_SECRET_KEY`
42-
- Value: generate it using `python -c "import secrets; print(secrets.token_urlsafe(50))"`
43-
6. Delete this section and make a second commit
49+
**------------------- END DELETE SECTION --------------------**
4450

4551
## Get started locally
4652

django/{{ cookiecutter.project_slug }}/pyproject.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ dependencies = [
99
"django-admin-interface>=0.30.0",
1010
"django-debug-toolbar>=5.2.0",
1111
"django-environ>=0.12.0",
12-
"gunicorn>=23.0.0",
1312
"psycopg[binary]>=3.2.9",
1413
"whitenoise>=6.9.0",
1514
]
@@ -18,3 +17,6 @@ dependencies = [
1817
dev = [
1918
"pre-commit>=4.2.0",
2019
]
20+
production = [
21+
"gunicorn>=23.0.0",
22+
]

django/{{ cookiecutter.project_slug }}/{{ cookiecutter.project_slug }}/settings/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

3939
# Security
4040

41-
SECRET_KEY = env.str("DJANGO_SECRET_KEY", "{{ random_ascii_string(48) }}")
41+
SECRET_KEY = env.str("DJANGO_SECRET_KEY", "{{ random_ascii_string(50) }}")
4242
X_FRAME_OPTIONS = "SAMEORIGIN"
4343
SILENCED_SYSTEM_CHECKS = ["security.W019"]
4444

0 commit comments

Comments
 (0)