Skip to content

Commit dccedaf

Browse files
authored
feat: modernize Docker Compose setup and simplify installation docs (#544)
Signed-off-by: tdruez <tdruez@aboutcode.org>
1 parent 5062051 commit dccedaf

11 files changed

Lines changed: 450 additions & 314 deletions

File tree

.devcontainer/demo/devcontainer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "DejaCode Demo (Codespaces only)",
3-
"dockerComposeFile": "../../docker-compose.demo.yml",
3+
"dockerComposeFile": "../../compose.demo.yml",
44
"service": "web",
55
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
66
"overrideCommand": false,
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Run unit tests
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
push:
7+
branches:
8+
- main
9+
10+
jobs:
11+
check-code-and-docs-validation:
12+
runs-on: ubuntu-24.04
13+
permissions:
14+
contents: read
15+
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
19+
with:
20+
persist-credentials: false # do not keep the token around
21+
22+
- name: Set up Python
23+
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
24+
with:
25+
python-version: "3.14"
26+
27+
- name: Install uv from vendored wheel
28+
run: pip install --no-index --find-links=./thirdparty/dist uv
29+
30+
- name: Validate code format
31+
run: make check
32+
33+
- name: Build the documentation
34+
run: make docs

.github/workflows/run-unit-tests.yml

Lines changed: 0 additions & 75 deletions
This file was deleted.

Makefile

Lines changed: 73 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,84 @@
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+
980
VENV_LOCATION=.venv
1081
ACTIVATE?=. ${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
1384
GET_SECRET_KEY=`head -c50 /dev/urandom | base64 | head -c50`
1485
# Customize with `$ make envfile ENV_FILE=/etc/dejacode/.env`
1586
ENV_FILE=.env
16-
DOCS_LOCATION=./docs
1787
DOCKER_COMPOSE=docker compose -f docker-compose.yml
1888
DOCKER_EXEC=${DOCKER_COMPOSE} exec
1989
DB_NAME=dejacode_db
@@ -23,19 +93,6 @@ DB_CONTAINER_NAME=db
2393
DB_INIT_FILE=./data/postgresql/initdb.sql.gz
2494
POSTGRES_INITDB_ARGS=--encoding=UTF-8 --lc-collate=en_US.UTF-8 --lc-ctype=en_US.UTF-8
2595
TIMESTAMP=$(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

4097
conf: 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-
116151
check-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-
190177
psql:
191178
${DOCKER_EXEC} ${DB_CONTAINER_NAME} psql --username=${DB_USERNAME} postgres
192179

193180
# $ make log SERVICE=db
194181
log:
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

README.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ DejaCode
33
========
44

55
DejaCode provides an enterprise-level application to automate open source license
6-
compliance and ensure software supply chain integrity, powered by `ScanCode <https://github.com/aboutcode-org/scancode-toolkit>`_,
6+
compliance and ensure software supply chain integrity, powered by
7+
`ScanCode <https://github.com/aboutcode-org/scancode-toolkit>`_,
78
the industry-leading code scanner.
89

910
Why Use DejaCode?

compose.build.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: dejacode
2+
3+
x-description: "Build override: builds the app image from source instead of using the pre-built image"
4+
5+
services:
6+
web:
7+
build: .
8+
9+
worker:
10+
build: .
11+
12+
scheduler:
13+
build: .
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
name: dejacode
1+
name: dejacode-demo
2+
3+
x-description: "Minimal demo stack: web + db only, auto-created superuser, Codespaces-ready"
4+
25
services:
36
db:
47
image: docker.io/library/postgres:16.13
@@ -7,8 +10,9 @@ services:
710
volumes:
811
- ./data/postgresql:/docker-entrypoint-initdb.d/
912
shm_size: "1gb"
13+
restart: always
1014
healthcheck:
11-
test: [ "CMD-SHELL", "pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB}" ]
15+
test: ["CMD-SHELL", "pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB}"]
1216
interval: 10s
1317
timeout: 5s
1418
retries: 5

0 commit comments

Comments
 (0)