Skip to content

Commit 5062051

Browse files
authored
feat: try DejaCode in GitHub Codespaces (#543)
Signed-off-by: tdruez <tdruez@aboutcode.org>
1 parent 3493e35 commit 5062051

5 files changed

Lines changed: 102 additions & 1 deletion

File tree

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"name": "DejaCode Demo (Codespaces only)",
3+
"dockerComposeFile": "../../docker-compose.demo.yml",
4+
"service": "web",
5+
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
6+
"overrideCommand": false,
7+
"forwardPorts": [8000],
8+
"portsAttributes": {
9+
"8000": {
10+
"label": "DejaCode",
11+
"onAutoForward": "notify"
12+
}
13+
},
14+
"customizations": {
15+
"codespaces": {
16+
"openFiles": []
17+
},
18+
"vscode": {
19+
"settings": {
20+
"chat.disableAIFeatures": true,
21+
"workbench.startupEditor": "none",
22+
"workbench.tips.enabled": false,
23+
"git.openRepositoryInParentFolders": "never"
24+
}
25+
}
26+
}
27+
}

.env.demo

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
POSTGRES_DB=dejacode_demo_db
2+
POSTGRES_USER=dejacode
3+
POSTGRES_PASSWORD=dejacode
4+
POSTGRES_INITDB_ARGS="--encoding=UTF-8 --lc-collate=en_US.UTF-8 --lc-ctype=en_US.UTF-8"
5+
6+
DATABASE_HOST=db
7+
DATABASE_NAME=dejacode_demo_db
8+
DATABASE_USER=dejacode
9+
DATABASE_PASSWORD=dejacode
10+
11+
SECRET_KEY=insecure-demo-key
12+
DEJACODE_DEBUG=True
13+
ALLOWED_HOSTS=*
14+
CSRF_TRUSTED_ORIGINS="https://*.app.github.dev,http://localhost:8000"
15+
X_FRAME_OPTIONS=SAMEORIGIN
16+
SECURE_CROSS_ORIGIN_OPENER_POLICY=None
17+
18+
DEJACODE_ASYNC=False
19+
CLAMD_ENABLED=False
20+
21+
DJANGO_SUPERUSER_USERNAME=demo
22+
DJANGO_SUPERUSER_EMAIL=demo@example.com
23+
DJANGO_SUPERUSER_PASSWORD=demo
24+
LOGIN_FORM_ALERT='<div class="alert alert-success">Username: demo<br>Password: demo</div>'

README.rst

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,28 @@ licenses, vulnerabilities, and package provenance and metadata, enabling you to
1414
FOSS compliance with enterprise-grade features and integrations for DevOps and
1515
software systems.
1616

17+
Try DejaCode in GitHub Codespaces
18+
=================================
19+
20+
You can try DejaCode instantly in your browser, **without installing anything**,
21+
using GitHub Codespaces. The badge below launches a ready-to-use demo instance:
22+
the application starts automatically, with a demo account already created for you.
23+
24+
.. image:: https://github.com/codespaces/badge.svg
25+
:target: https://github.com/codespaces/new/aboutcode-org/dejacode?ref=main&devcontainer_path=.devcontainer%2Fdemo%2Fdevcontainer.json&quickstart=true
26+
:alt: Open in GitHub Codespaces
27+
28+
#. **Click** the badge above and **confirm** the creation of the Codespace.
29+
#. **Wait** for the environment to finish starting. This takes a few minutes the
30+
first time.
31+
#. **Open the app** when the notification offers to. You can also open it anytime
32+
from the **Ports** tab by clicking the globe icon next to port ``8000``.
33+
#. **Log in** with the demo credentials shown on the login page.
34+
35+
**Note:**
36+
This demo instance is **ephemeral** and meant for evaluation only. Data is not
37+
preserved, and the instance shuts down after a period of inactivity.
38+
1739
Getting Started
1840
===============
1941

dejacode/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,8 @@ def gettext_noop(s):
202202
SECURE_CROSS_ORIGIN_OPENER_POLICY = env.str(
203203
"SECURE_CROSS_ORIGIN_OPENER_POLICY", default="same-origin"
204204
)
205+
X_FRAME_OPTIONS = env.str("X_FRAME_OPTIONS", default="DENY")
205206

206-
X_FRAME_OPTIONS = "DENY"
207207
# Note: The CSRF_COOKIE_HTTPONLY cannot be activated yet without breaking all
208208
# the AJAX (POST, PUT, etc..) requests, like the annotation system for example.
209209
# It will be required to configure the following:

docker-compose.demo.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: dejacode
2+
services:
3+
db:
4+
image: docker.io/library/postgres:16.13
5+
env_file:
6+
- .env.demo
7+
volumes:
8+
- ./data/postgresql:/docker-entrypoint-initdb.d/
9+
shm_size: "1gb"
10+
healthcheck:
11+
test: [ "CMD-SHELL", "pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB}" ]
12+
interval: 10s
13+
timeout: 5s
14+
retries: 5
15+
16+
web:
17+
image: ghcr.io/aboutcode-org/dejacode:latest
18+
command: sh -c "
19+
./manage.py migrate &&
20+
(./manage.py createsuperuser --noinput || true) &&
21+
./manage.py runserver --insecure --skip-checks 0.0.0.0:8000"
22+
env_file:
23+
- .env.demo
24+
ports:
25+
- "8000:8000"
26+
depends_on:
27+
db:
28+
condition: service_healthy

0 commit comments

Comments
 (0)