forked from ungleich-public/dynamicweb
Let UNGLEICH_SITE_ALIASES show a site on another host
This commit is contained in:
parent
1c57cd6024
commit
7bb95c14d3
3 changed files with 10 additions and 1 deletions
|
|
@ -85,6 +85,8 @@ See [K8S.md](K8S.md) for the Kubernetes deployment.
|
|||
|
||||
- `.env.docker`: committed dev defaults. `.env`: your overrides (git-ignored).
|
||||
- Add a site: add it to `UNGLEICH_SITE_CONFIGS` (a `Site` row is created on start).
|
||||
- Show an existing site on another host (a demo domain): `UNGLEICH_SITE_ALIASES={"demo.example.org":"datacenterlight.ch"}`.
|
||||
`migrate` creates the alias and the host is added to `ALLOWED_HOSTS`. Unknown hosts are redirected to datacenterlight.ch.
|
||||
- Web server tuning: `GUNICORN_WORKERS` (3), `GUNICORN_TIMEOUT` (120).
|
||||
- Sample data off: `SEED_DUMMY_DATA=False`. Remove it later:
|
||||
`docker compose exec web python manage.py seed_dummy_data --purge`.
|
||||
|
|
|
|||
|
|
@ -5,7 +5,8 @@ It replaces Django's own "migrate", so "python manage.py migrate" is all that ha
|
|||
- skips the migration-history consistency check when it fails, as it does on old databases
|
||||
that record some migrations as applied before the (newer) migrations they now depend on
|
||||
- gives pages that have no tree node one (see give_orphan_pages_a_node) before cms 0020
|
||||
- makes sure every site in UNGLEICH_SITE_CONFIGS exists
|
||||
- makes sure every site in UNGLEICH_SITE_CONFIGS exists, and every host in
|
||||
UNGLEICH_SITE_ALIASES ({"alias host": "site domain"}) shows that site
|
||||
"""
|
||||
import json
|
||||
import os
|
||||
|
|
@ -17,6 +18,7 @@ from django.db.migrations.executor import MigrationExecutor
|
|||
from django.db.migrations.exceptions import InconsistentMigrationHistory
|
||||
from django.db.migrations.loader import MigrationLoader
|
||||
from django.db.migrations.recorder import MigrationRecorder
|
||||
from multisite.models import Alias
|
||||
|
||||
REVERSION_SQUASH = '0001_squashed_0004_auto_20160611_1202'
|
||||
REVERSION_FIXES = (
|
||||
|
|
@ -52,6 +54,8 @@ class Command(migrate.Command):
|
|||
if not dry_run and not options["app_label"]:
|
||||
for domain in json.loads(os.environ.get('UNGLEICH_SITE_CONFIGS') or '{}'):
|
||||
Site.objects.get_or_create(domain=domain, defaults={'name': domain})
|
||||
for alias, domain in json.loads(os.environ.get('UNGLEICH_SITE_ALIASES') or '{}').items():
|
||||
Alias.objects.get_or_create(domain=alias, defaults={'site': Site.objects.get(domain=domain)})
|
||||
|
||||
@staticmethod
|
||||
def cms_tree_done():
|
||||
|
|
|
|||
|
|
@ -26,3 +26,6 @@ ALLOWED_HOSTS = [
|
|||
".hack4glarus.ch",
|
||||
".xn--nglarus-n2a.ch"
|
||||
]
|
||||
|
||||
# hosts that UNGLEICH_SITE_ALIASES maps onto a site are allowed as well
|
||||
ALLOWED_HOSTS += list(json.loads(env('UNGLEICH_SITE_ALIASES', '{}')))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue