From 920348637e976691315d0cac4317fd48142aaabd Mon Sep 17 00:00:00 2001 From: Sajeyks Date: Wed, 30 Sep 2026 16:49:20 +0300 Subject: [PATCH] Rewrite docker guide: VPS quick start, production checklist, known limits --- DOCKER.md | 121 +++++++++++++++++++++--------------------------------- 1 file changed, 46 insertions(+), 75 deletions(-) diff --git a/DOCKER.md b/DOCKER.md index 9b5cd2ad..b731693a 100644 --- a/DOCKER.md +++ b/DOCKER.md @@ -1,31 +1,41 @@ # Running dynamicweb with Docker Compose -A self-contained test/dev stack: Postgres, Redis, the web app and a Celery worker. -Nothing else needs to be installed on the server. +Postgres, Redis, the web app and a Celery worker in one stack. Only Docker is needed. -## Start +## Quick start (VPS or local) ```sh git clone && cd dynamicweb docker compose up -d --build -docker compose logs -f web # wait for "Starting development server" +docker compose logs -f web # ready when it prints "Starting development server" ``` -The first start takes a few minutes: it builds the image, creates the database, -runs all migrations and generates a Django secret key (kept in the `appdata` volume). +The first start takes a few minutes (image build, migrations, secret key, sample data). +Open port **8000** in the server firewall, then in your browser go to: -The app listens on port **8000**. Open it at `http://:8000/` -(open the port in the server firewall if needed). +- **VPS:** `http://:8000/dev-sites/` +- **Local machine:** `http://localhost:8000/dev-sites/` -## Configuration +That page lists all 14 sites as links. Each opens as its own site, so you can keep several +open in different tabs. (On a VPS the links look like `http://..sslip.io:8000/`; +sslip.io is public wildcard DNS, so your *browser* needs internet, the server doesn't.) -- Defaults for everything are in `.env.docker` (committed, dev values only). -- To override a value, create a `.env` file next to `docker-compose.yml` - (optional, git-ignored). Values there win over `.env.docker`. +Admin login: `dummy-admin@example.com` / `dummy-admin` at `/en-us/admin/login/` +(on any site address). -### Using your own Postgres instead of the bundled one +## What you will see -Set the connection in `.env`: +- Every site has sample pages (Home, About, Services, Pricing, Contact) with realistic text. +- ungleich.ch (and blog, comic), datacenterlight.ch and digitalglarus.ch use their own + design. **The templates of the other 9 sites are not known**, so they show the plain + Digital Glarus page. That is a test-data limit, not a bug: in production every site's + pages and template come from the CMS database. +- OpenNebula (VM creation), LDAP login and Stripe payments are placeholders and will not + work. Email is printed in the web log. + +## Deploying with your own Postgres (production-like) + +Create `.env` next to `docker-compose.yml`; values there override `.env.docker`: ``` POSTGRES_HOST= @@ -33,79 +43,40 @@ POSTGRES_PORT=5432 POSTGRES_DB= POSTGRES_USER= POSTGRES_PASSWORD= +SEED_DUMMY_DATA=False +DEBUG=False +UNGLEICH_SITE_CONFIGS= ``` -then start everything except the bundled database: +plus your real OpenNebula, LDAP, Stripe, email and reCAPTCHA values. Then: ```sh docker compose up -d --build --no-deps web celery redis ``` -## Testing all the sites +Checklist: -The project serves many websites from one app and chooses the site from the -hostname. In this test setup you don't need DNS or `/etc/hosts`: a dev-only -switcher (active when `DEBUG=True`) reads the site from the address, so every site -is its own browser origin and you can open several at once. +- The database already holds the pages, sites and templates (they are stored in the + CMS; nothing is created for you). Sample data is skipped anyway when it finds page content. +- `DEBUG=False` loads the production settings and turns off the `/dev-sites/` switcher, + so reach each site by its real domain name. +- The web container runs Django's `runserver`; put a real web server or proxy in front + for real traffic. -- On the machine running the stack, browsers resolve `.localhost` to - the local machine, so the links below just work. -- On a remote server, open **`http://:8000/dev-sites/`**: it lists every site as a - link of the form `http://..sslip.io:8000/` (sslip.io is a public wildcard DNS - service, so the server needs internet access from your browser, not from itself). -- Fallback without wildcard names: `http://:8000/?site=` remembers the - site in a cookie (shared by all tabs, so prefer the addresses above). +## Configuration -| Site | Link | -|---|---| -| ungleich.ch | http://ungleich.ch.localhost:8000/ | -| blog.ungleich.ch | http://blog.ungleich.ch.localhost:8000/ | -| comic.ungleich.ch | http://comic.ungleich.ch.localhost:8000/ | -| digitalglarus.ch | http://digitalglarus.ch.localhost:8000/ | -| datacenterlight.ch | http://datacenterlight.ch.localhost:8000/ | -| rails-hosting.ch | http://rails-hosting.ch.localhost:8000/ | -| django-hosting.ch | http://django-hosting.ch.localhost:8000/ | -| node-hosting.ch | http://node-hosting.ch.localhost:8000/ | -| devuanhosting.ch | http://devuanhosting.ch.localhost:8000/ | -| devuanhosting.com | http://devuanhosting.com.localhost:8000/ | -| ipv6onlyhosting.com | http://ipv6onlyhosting.com.localhost:8000/ | -| digitalezukunft.ch | http://digitalezukunft.ch.localhost:8000/ | -| hack4glarus.ch | http://hack4glarus.ch.localhost:8000/ | -| xn--nglarus-n2a.ch | http://xn--nglarus-n2a.ch.localhost:8000/ | - -To add a site, add it to -`UNGLEICH_SITE_CONFIGS` in `.env.docker` (a `Site` row is created on start). - -## Dummy data - -With `SEED_DUMMY_DATA=True` (the default in `.env.docker`), a start on a database -without page content creates sample content that mimics production: per site a home page -in that site's own template with four child pages (About, Services, Pricing, Contact), -plus an admin and 12 customers. The text is written to look like a real site, and only -hidden markers (page `reverse_id` starting with `dummy-`, `dummy-*@example.com` users) -identify it. If the database already has page content (for example the owner's own Postgres) -nothing is added. It is idempotent and only touches what it created. - -- Admin login (fixed): `dummy-admin@example.com` / `dummy-admin` at `/en-us/admin/login/`. - Change the password with `DUMMY_ADMIN_PASSWORD` in `.env` (applies when the admin is first created). -- Turn it off with `SEED_DUMMY_DATA=False` in `.env`. -- Remove it at any time: `docker compose exec web python manage.py seed_dummy_data --purge`. - -Real data can also be restored from a plain-SQL `*.sql` / `*.sql.gz` dump in `db-init/` -before the first start. To reload: `docker compose down -v` (deletes volumes) and start -again. Dumps are git-ignored because they contain personal data. +- `.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). +- Sample data off: `SEED_DUMMY_DATA=False`. Remove it later: + `docker compose exec web python manage.py seed_dummy_data --purge`. +- Restore a real dump: put a `.sql` or `.sql.gz` file in `db-init/`, then + `docker compose down -v` and start again (dumps are git-ignored). ## Useful commands ```sh -docker compose ps # what is running -docker compose logs -f web celery # logs -docker compose up -d --build # rebuild after code changes (code is baked into the image) -docker compose exec web python manage.py createsuperuser -docker compose down # stop (keeps data); add -v to wipe it +docker compose ps # what is running +docker compose logs -f web celery # logs +docker compose up -d --build # after code changes (code is baked into the image) +docker compose down # stop, keep data (-v wipes it) ``` - -## Limitations of the test setup - -OpenNebula (VM creation), LDAP login and Stripe payments use placeholders and -will not work. Email is printed to the web container log. `DEBUG=True` is on.