Skip to content
This repository was archived by the owner on Jun 2, 2026. It is now read-only.

Commit 48fb63f

Browse files
committed
compose file for local dojo instance: openapi spec refresh no longer restricted to live demo
1 parent a10acdd commit 48fb63f

4 files changed

Lines changed: 167 additions & 5 deletions

File tree

support/fetch_openapi.py

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,34 @@
11
#!/usr/bin/env python3
22

3+
import argparse
34
import json
5+
import subprocess
46
from pathlib import Path
57

68
import requests
79

8-
HOST = 'https://demo.defectdojo.org'
10+
DEMO_HOST = 'https://demo.defectdojo.org'
911
FILE = Path(__file__).parent / 'openapi.json'
1012

1113

1214
def main():
13-
r = requests.get(f'{HOST.rstrip("/")}/api/v2/oa3/schema/', params={'format': 'json'})
14-
r.raise_for_status()
15-
with FILE.open('w') as f:
16-
json.dump(r.json(), f, indent=4)
15+
p = argparse.ArgumentParser()
16+
p.add_argument('-d', '--demo', action='store_true', help='Use live demo instead of local Dojo instance')
17+
args = p.parse_args()
18+
if args.demo:
19+
host = DEMO_HOST
20+
else:
21+
subprocess.check_call([Path(__file__).parent / 'integration' / 'run_dojo.sh'])
22+
host = 'http://localhost:8080'
23+
24+
try:
25+
r = requests.get(f'{host}/api/v2/oa3/schema/', params={'format': 'json'})
26+
r.raise_for_status()
27+
with FILE.open('w') as f:
28+
json.dump(r.json(), f, indent=4)
29+
finally:
30+
if not args.demo:
31+
subprocess.check_call([Path(__file__).parent / 'integration' / 'stop_dojo.sh'])
1732

1833

1934
if __name__ == '__main__':
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
# copy from https://github.com/DefectDojo/django-DefectDojo/blob/master/docker-compose.yml
2+
3+
# This docker-compose.yml file is fully functional to evaluate DefectDojo
4+
# in your local environment.
5+
#
6+
# Although Docker Compose is one of the supported installation methods to
7+
# deploy a containerized DefectDojo in a production environment, the
8+
# docker-compose.yml file is not intended for production use without first
9+
# customizing it to your particular situation.
10+
---
11+
services:
12+
nginx:
13+
image: "defectdojo/defectdojo-nginx:${NGINX_VERSION:-latest}"
14+
depends_on:
15+
- uwsgi
16+
environment:
17+
NGINX_METRICS_ENABLED: "${NGINX_METRICS_ENABLED:-false}"
18+
DD_UWSGI_HOST: "${DD_UWSGI_HOST:-uwsgi}"
19+
DD_UWSGI_PORT: "${DD_UWSGI_PORT:-3031}"
20+
volumes:
21+
- defectdojo_media:/usr/share/nginx/html/media
22+
ports:
23+
- target: 8080
24+
published: ${DD_PORT:-8080}
25+
protocol: tcp
26+
mode: host
27+
- target: 8443
28+
published: ${DD_TLS_PORT:-8443}
29+
protocol: tcp
30+
mode: host
31+
uwsgi:
32+
image: "defectdojo/defectdojo-django:${DJANGO_VERSION:-latest}"
33+
depends_on:
34+
- initializer
35+
entrypoint: ['/wait-for-it.sh', '${DD_DATABASE_HOST:-postgres}:${DD_DATABASE_PORT:-5432}', '-t', '30', '--', '/entrypoint-uwsgi.sh']
36+
environment:
37+
DD_DEBUG: 'False'
38+
DD_DJANGO_METRICS_ENABLED: "${DD_DJANGO_METRICS_ENABLED:-False}"
39+
DD_ALLOWED_HOSTS: "${DD_ALLOWED_HOSTS:-*}"
40+
DD_DATABASE_URL: ${DD_DATABASE_URL:-postgresql://defectdojo:defectdojo@postgres:5432/defectdojo}
41+
DD_CELERY_BROKER_URL: ${DD_CELERY_BROKER_URL:-redis://redis:6379/0}
42+
DD_SECRET_KEY: "${DD_SECRET_KEY:-hhZCp@D28z!n@NED*yB!ROMt+WzsY*iq}"
43+
DD_CREDENTIAL_AES_256_KEY: "${DD_CREDENTIAL_AES_256_KEY:-&91a*agLqesc*0DJ+2*bAbsUZfR*4nLw}"
44+
DD_DATABASE_READINESS_TIMEOUT: "${DD_DATABASE_READINESS_TIMEOUT:-30}"
45+
volumes:
46+
- "defectdojo_media:${DD_MEDIA_ROOT:-/app/media}"
47+
celerybeat:
48+
image: "defectdojo/defectdojo-django:${DJANGO_VERSION:-latest}"
49+
depends_on:
50+
- postgres
51+
- redis
52+
entrypoint: ['/wait-for-it.sh', '${DD_DATABASE_HOST:-postgres}:${DD_DATABASE_PORT:-5432}', '-t', '30', '--', '/entrypoint-celery-beat.sh']
53+
environment:
54+
DD_DATABASE_URL: ${DD_DATABASE_URL:-postgresql://defectdojo:defectdojo@postgres:5432/defectdojo}
55+
DD_CELERY_BROKER_URL: ${DD_CELERY_BROKER_URL:-redis://redis:6379/0}
56+
DD_SECRET_KEY: "${DD_SECRET_KEY:-hhZCp@D28z!n@NED*yB!ROMt+WzsY*iq}"
57+
DD_CREDENTIAL_AES_256_KEY: "${DD_CREDENTIAL_AES_256_KEY:-&91a*agLqesc*0DJ+2*bAbsUZfR*4nLw}"
58+
DD_DATABASE_READINESS_TIMEOUT: "${DD_DATABASE_READINESS_TIMEOUT:-30}"
59+
celeryworker:
60+
image: "defectdojo/defectdojo-django:${DJANGO_VERSION:-latest}"
61+
depends_on:
62+
- postgres
63+
- redis
64+
entrypoint: ['/wait-for-it.sh', '${DD_DATABASE_HOST:-postgres}:${DD_DATABASE_PORT:-5432}', '-t', '30', '--', '/entrypoint-celery-worker.sh']
65+
environment:
66+
DD_DATABASE_URL: ${DD_DATABASE_URL:-postgresql://defectdojo:defectdojo@postgres:5432/defectdojo}
67+
DD_CELERY_BROKER_URL: ${DD_CELERY_BROKER_URL:-redis://redis:6379/0}
68+
DD_SECRET_KEY: "${DD_SECRET_KEY:-hhZCp@D28z!n@NED*yB!ROMt+WzsY*iq}"
69+
DD_CREDENTIAL_AES_256_KEY: "${DD_CREDENTIAL_AES_256_KEY:-&91a*agLqesc*0DJ+2*bAbsUZfR*4nLw}"
70+
DD_DATABASE_READINESS_TIMEOUT: "${DD_DATABASE_READINESS_TIMEOUT:-30}"
71+
volumes:
72+
- "defectdojo_media:${DD_MEDIA_ROOT:-/app/media}"
73+
initializer:
74+
image: "defectdojo/defectdojo-django:${DJANGO_VERSION:-latest}"
75+
depends_on:
76+
- postgres
77+
entrypoint: ['/wait-for-it.sh', '${DD_DATABASE_HOST:-postgres}:${DD_DATABASE_PORT:-5432}', '--', '/entrypoint-initializer.sh']
78+
environment:
79+
DD_DATABASE_URL: ${DD_DATABASE_URL:-postgresql://defectdojo:defectdojo@postgres:5432/defectdojo}
80+
DD_ADMIN_USER: "${DD_ADMIN_USER:-admin}"
81+
DD_ADMIN_MAIL: "${DD_ADMIN_USER:-admin@defectdojo.local}"
82+
DD_ADMIN_FIRST_NAME: "${DD_ADMIN_FIRST_NAME:-Admin}"
83+
DD_ADMIN_LAST_NAME: "${DD_ADMIN_LAST_NAME:-User}"
84+
DD_INITIALIZE: "${DD_INITIALIZE:-true}"
85+
DD_SECRET_KEY: "${DD_SECRET_KEY:-hhZCp@D28z!n@NED*yB!ROMt+WzsY*iq}"
86+
DD_CREDENTIAL_AES_256_KEY: "${DD_CREDENTIAL_AES_256_KEY:-&91a*agLqesc*0DJ+2*bAbsUZfR*4nLw}"
87+
DD_DATABASE_READINESS_TIMEOUT: "${DD_DATABASE_READINESS_TIMEOUT:-30}"
88+
DD_ADMIN_PASSWORD: admin
89+
postgres:
90+
image: postgres:17.4-alpine
91+
environment:
92+
POSTGRES_DB: ${DD_DATABASE_NAME:-defectdojo}
93+
POSTGRES_USER: ${DD_DATABASE_USER:-defectdojo}
94+
POSTGRES_PASSWORD: ${DD_DATABASE_PASSWORD:-defectdojo}
95+
volumes:
96+
- defectdojo_postgres:/var/lib/postgresql/data
97+
redis:
98+
# Pinning to this version due to licensing constraints
99+
image: redis:7.2.8-alpine
100+
volumes:
101+
- defectdojo_redis:/data
102+
volumes:
103+
defectdojo_postgres: {}
104+
defectdojo_media: {}
105+
defectdojo_redis: {}

support/integration/run_dojo.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/bash
2+
# written by Copilot
3+
4+
set -eo pipefail
5+
6+
cd $(dirname $0)
7+
8+
COMPOSE_FILE="docker-compose.yml"
9+
SERVICE_URL="http://localhost:8080"
10+
TIMEOUT=300
11+
INTERVAL=2
12+
export DJANGO_VERSION="2.46.2"
13+
export NGINX_VERSION="${DJANGO_VERSION}"
14+
15+
# Start docker compose in detached mode
16+
docker compose -f "$COMPOSE_FILE" up -d
17+
18+
echo "Waiting for service to be ready at $SERVICE_URL..."
19+
20+
SECONDS=0
21+
while (( SECONDS < TIMEOUT )); do
22+
STATUS=$(curl -s -o /dev/null -Lw "%{http_code}" "$SERVICE_URL" || true)
23+
if [[ "$STATUS" == "200" ]]; then
24+
echo "Service is ready!"
25+
exit 0
26+
fi
27+
# echo "NOT READY: status $STATUS"
28+
sleep $INTERVAL
29+
done
30+
31+
echo "Service did not become ready within $TIMEOUT seconds."
32+
exit 1

support/integration/stop_dojo.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
# written by Copilot
3+
4+
set -eo pipefail
5+
6+
cd $(dirname $0)
7+
8+
COMPOSE_FILE="docker-compose.yml"
9+
10+
docker compose -f "$COMPOSE_FILE" down

0 commit comments

Comments
 (0)