66# See https://aboutcode.org for more information about AboutCode FOSS projects.
77#
88
9+ # #######################################################################################
10+ # Docker dev commands
11+ # #######################################################################################
12+
13+ IMAGE_NAME =dejacode:dev
14+ COMPOSE =docker compose -f compose.dev.yml
15+ MANAGE =${COMPOSE} exec web ./manage.py
16+ EXEC =${COMPOSE} exec
17+
18+ run :
19+ @echo " -> Run the Docker compose services in dev mode (hot reload on code changes)"
20+ ${COMPOSE} up
21+
22+ bash :
23+ # Open a bash session in the running web container
24+ ${COMPOSE} exec web bash
25+
26+ shell :
27+ # Open a bash session in a standalone container (no stack required)
28+ docker run -it $(IMAGE_NAME ) bash
29+
30+ test :
31+ @echo " -> Run the test suite"
32+ ${MANAGE} test --noinput --parallel auto
33+
34+ migrations :
35+ @echo " -> Creates new database migrations"
36+ ${MANAGE} makemigrations
37+
38+ migrate :
39+ @echo " -> Apply database migrations"
40+ ${MANAGE} migrate
41+
42+ build :
43+ @echo " -> Build the dev Docker images"
44+ ${COMPOSE} build
45+
46+ superuser :
47+ ${MANAGE} createsuperuser
48+
49+ # #######################################################################################
50+ # Utilities
51+ # #######################################################################################
52+
53+ DOCS_LOCATION =./docs
54+
55+ doc8 :
56+ @echo " -> Run documentation .rst validation"
57+ uvx doc8==2.0.0 --max-line-length 100 --ignore-path docs/_build/ --quiet docs/
58+
59+ valid :
60+ @echo " -> Run Ruff format"
61+ uvx ruff format
62+ @echo " -> Run Ruff linter"
63+ uvx ruff check --fix
64+
65+ check :
66+ @echo " -> Run Ruff linter validation (pycodestyle, bandit, isort, and more)"
67+ uvx ruff check
68+ @echo " -> Run Ruff format validation"
69+ uvx ruff format --check
70+ @$(MAKE ) doc8
71+
72+ docs :
73+ @echo " -> Builds the documentation"
74+ rm -rf ${DOCS_LOCATION} /_build/
75+ uvx --from sphinx==9.1.0 --with furo==2025.12.19 sphinx-build -b singlehtml ${DOCS_LOCATION} ${DOCS_LOCATION} /_build/singlehtml/
76+ uvx --from sphinx==9.1.0 --with furo==2025.12.19 sphinx-build -b html ${DOCS_LOCATION} ${DOCS_LOCATION} /_build/html/
77+
78+ # #######################################################################################
79+
980VENV_LOCATION =.venv
1081ACTIVATE? =. ${VENV_LOCATION}/bin/activate;
11- MANAGE =${VENV_LOCATION}/bin/python manage.py
82+ # MANAGE=${VENV_LOCATION}/bin/python manage.py
1283# Do not depend on Python to generate the SECRET_KEY
1384GET_SECRET_KEY =` head -c50 /dev/urandom | base64 | head -c50 `
1485# Customize with `$ make envfile ENV_FILE=/etc/dejacode/.env`
1586ENV_FILE =.env
16- DOCS_LOCATION =./docs
1787DOCKER_COMPOSE =docker compose -f docker-compose.yml
1888DOCKER_EXEC =${DOCKER_COMPOSE} exec
1989DB_NAME =dejacode_db
@@ -23,19 +93,6 @@ DB_CONTAINER_NAME=db
2393DB_INIT_FILE =./data/postgresql/initdb.sql.gz
2494POSTGRES_INITDB_ARGS=--encoding =UTF-8 --lc-collate=en_US.UTF-8 --lc-ctype=en_US.UTF-8
2595TIMESTAMP =$(shell date +"% Y-% m-% d_% H% M")
26- IMAGE_NAME =dejacode
27-
28- # Use sudo for postgres, only on Linux
29- UNAME := $(shell uname)
30- ifeq ($(UNAME ) , Linux)
31- SUDO_POSTGRES=sudo -u postgres
32- else
33- SUDO_POSTGRES=
34- endif
35-
36- virtualenv :
37- @echo " -> Bootstrap the virtualenv with uv"
38- uv venv --allow-existing ${VENV_LOCATION}
3996
4097conf : virtualenv
4198 @echo " -> Install dependencies"
@@ -91,28 +148,6 @@ envfile_dev: envfile
91148 @echo " -> Update the .env file for development"
92149 @echo DATABASE_PASSWORD=\" dejacode\" >> ${ENV_FILE}
93150
94- doc8 :
95- @echo " -> Run documentation .rst validation"
96- uvx doc8==2.0.0 --max-line-length 100 --ignore-path docs/_build/ --quiet docs/
97-
98- valid :
99- @echo " -> Run Ruff format"
100- @${ACTIVATE} ruff format
101- @echo " -> Run Ruff linter"
102- @${ACTIVATE} ruff check --fix
103-
104- check :
105- @echo " -> Run Ruff linter validation (pycodestyle, bandit, isort, and more)"
106- @${ACTIVATE} ruff check
107- @echo " -> Run Ruff format validation"
108- @${ACTIVATE} ruff format --check
109- @echo " -> Running ABOUT files validation"
110- @${ACTIVATE} about check ./thirdparty/
111- @${ACTIVATE} about check ./data/
112- @${ACTIVATE} about check ./dje/
113- @${ACTIVATE} about check ./dejacode_toolkit/
114- @$(MAKE ) doc8
115-
116151check-deploy :
117152 @echo " -> Check Django deployment settings"
118153 ${MANAGE} check --deploy
@@ -139,62 +174,11 @@ initdb:
139174 @echo " Starting Docker services"
140175 ${DOCKER_COMPOSE} start
141176
142- migrate :
143- @echo " -> Apply database migrations"
144- ${MANAGE} migrate
145-
146- postgresdb :
147- @echo " -> Configure PostgreSQL database"
148- @echo " -> Create database user ${DB_NAME} "
149- @${SUDO_POSTGRES} createuser --no-createrole --no-superuser --login --inherit --createdb ' ${DB_USERNAME}' || true
150- @${SUDO_POSTGRES} psql -c " alter user ${DB_USERNAME} with encrypted password '${DB_PASSWORD} ';" || true
151- @echo " -> Drop ${DB_NAME} database if exists"
152- @${SUDO_POSTGRES} dropdb ${DB_NAME} || true
153- @echo " -> Create ${DB_NAME} database: createdb --owner=${DB_USERNAME} ${POSTGRES_INITDB_ARGS} ${DB_NAME} "
154- @${SUDO_POSTGRES} createdb --owner=${DB_USERNAME} ${POSTGRES_INITDB_ARGS} ${DB_NAME}
155- @gunzip < ${DB_INIT_FILE} | psql --username=${DB_USERNAME} ${DB_NAME}
156- @echo " -> Apply database migrations"
157- ${MANAGE} migrate
158-
159- postgresdb_clean :
160- @echo " -> Drop PostgreSQL user and database"
161- @${SUDO_POSTGRES} dropdb ${DB_NAME} || true
162- @${SUDO_POSTGRES} dropuser ' ${DB_USERNAME}' || true
163-
164- run :
165- DJANGO_RUNSERVER_HIDE_WARNING=true ${MANAGE} runserver 8000 --insecure
166-
167- worker :
168- ${MANAGE} rqworker
169-
170- test :
171- @echo " -> Run the test suite"
172- ${MANAGE} test --noinput --parallel auto
173-
174- docs :
175- @echo " -> Builds the documentation"
176- rm -rf ${DOCS_LOCATION} /_build/
177- uvx --from sphinx==9.1.0 --with furo==2025.12.19 sphinx-build -b singlehtml ${DOCS_LOCATION} ${DOCS_LOCATION} /_build/singlehtml/
178- uvx --from sphinx==9.1.0 --with furo==2025.12.19 sphinx-build -b html ${DOCS_LOCATION} ${DOCS_LOCATION} /_build/html/
179-
180- build :
181- @echo " -> Build the Docker image"
182- docker build -t $(IMAGE_NAME ) .
183-
184- bash :
185- docker run -it $(IMAGE_NAME ) bash
186-
187- shell :
188- ${DOCKER_EXEC} web ./manage.py shell
189-
190177psql :
191178 ${DOCKER_EXEC} ${DB_CONTAINER_NAME} psql --username=${DB_USERNAME} postgres
192179
193180# $ make log SERVICE=db
194181log :
195182 ${DOCKER_COMPOSE} logs --tail=" 100" ${SERVICE}
196183
197- createsuperuser :
198- ${DOCKER_EXEC} web ./manage.py createsuperuser
199-
200- .PHONY : virtualenv conf dev lock upgrade envfile envfile_dev check outdated doc8 valid check-deploy clean initdb postgresdb postgresdb_clean migrate run test docs build psql bash shell log createsuperuser
184+ .PHONY : virtualenv conf dev lock upgrade envfile envfile_dev check outdated doc8 valid check-deploy clean initdb postgresdb postgresdb_clean migrate run test docs build psql bash shell log superuser
0 commit comments