Skip to content

Commit

Permalink
Fixed django#1817 -- Added tracdb container
Browse files Browse the repository at this point in the history
Added 'tracdb' container to compose file. Simplified docker settings to
remove duplication. Added support for 'secrets.json' in the docker dev
stage. Added the 'DJANGOPROJECT_DATA_DIR' env var to tox.
  • Loading branch information
pbratkowski committed Dec 13, 2024
1 parent 5424f72 commit 9fbab4a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 74 deletions.
78 changes: 5 additions & 73 deletions djangoproject/settings/docker.py
Original file line number Diff line number Diff line change
@@ -1,76 +1,8 @@
from .common import * # noqa

DATABASES = {
"default": {
"ENGINE": os.environ.get("SQL_ENGINE"),
"NAME": os.environ.get("SQL_DATABASE"),
"USER": os.environ.get("SQL_USER"),
"PASSWORD": os.environ.get("SQL_PASSWORD"),
"HOST": os.environ.get("SQL_HOST"),
"PORT": os.environ.get("SQL_PORT"),
}
}

SECRET_KEY = os.environ.get("SECRET_KEY")

SILENCED_SYSTEM_CHECKS = SILENCED_SYSTEM_CHECKS + [
"django_recaptcha.recaptcha_test_key_error" # Default test keys for development.
]

ALLOWED_HOSTS = [".localhost", "127.0.0.1", "www.127.0.0.1"]

LOCALE_MIDDLEWARE_EXCLUDED_HOSTS = ["docs.djangoproject.localhost"]

DEBUG = True
THUMBNAIL_DEBUG = DEBUG

CACHES = {
"default": {
"BACKEND": "django.core.cache.backends.locmem.LocMemCache",
"LOCATION": "trololololol",
},
"docs-pages": {
"BACKEND": "django.core.cache.backends.locmem.LocMemCache",
"LOCATION": "docs-pages",
},
}

CSRF_COOKIE_SECURE = False

EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend"

MEDIA_ROOT = str(DATA_DIR.joinpath("media_root"))

SESSION_COOKIE_SECURE = False

STATIC_ROOT = str(DATA_DIR.joinpath("static_root"))

# Docs settings
DOCS_BUILD_ROOT = DATA_DIR.joinpath("djangodocs")
from .dev import * # noqa

# django-hosts settings
if parent_host := SECRETS.get("parent_host"):
PARENT_HOST = parent_host

PARENT_HOST = "localhost:8000"

# django-push settings

PUSH_SSL_CALLBACK = False

# Enable optional components

if DEBUG:
try:
import debug_toolbar # NOQA
except ImportError:
pass
else:
INSTALLED_APPS.append("debug_toolbar")
INTERNAL_IPS = ["127.0.0.1"]
MIDDLEWARE.insert(
MIDDLEWARE.index("django.middleware.common.CommonMiddleware") + 1,
"debug_toolbar.middleware.DebugToolbarMiddleware",
)
MIDDLEWARE.insert(
MIDDLEWARE.index("debug_toolbar.middleware.DebugToolbarMiddleware") + 1,
"djangoproject.middleware.CORSMiddleware",
)
# debug-toolbar settings
INTERNAL_IPS = SECRETS.get("internal_ips", ["127.0.0.1"])
8 changes: 8 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,11 @@ services:
- POSTGRES_USER=djangoproject
- POSTGRES_PASSWORD=secret
- POSTGRES_DB=djangoproject
tracdb:
image: postgres:14-alpine
environment:
- POSTGRES_USER=code.djangoproject
- POSTGRES_PASSWORD=secret
- POSTGRES_DB=code.djangoproject
volumes:
- ./tracdb/trac.sql:/docker-entrypoint-initdb.d/trac.sql
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ python =

[testenv]
allowlist_externals = make
passenv = DJANGO_SETTINGS_MODULE
passenv = DJANGO_SETTINGS_MODULE, DJANGOPROJECT_DATA_DIR
deps =
tests: -r{toxinidir}/requirements/tests.txt
flake8: flake8
Expand Down

0 comments on commit 9fbab4a

Please sign in to comment.