Multisite-Konfiguration mit Docker

:warning: Obwohl Multisite von der Discourse-Anwendung unterstützt wird, handelt es sich hierbei um eine fortgeschrittene Sysadmin-Einrichtung. Wenn Sie nicht wissen, was Sie tun, richten Sie kein Multisite ein. Das Discourse-Team kann keine Unterstützung für die Multisite-Konfiguration anbieten.

Wenn Sie mehrere Domains auf einer einzigen Docker-Einrichtung hosten möchten, benötigen Sie eine Multisite-Konfiguration. Hier sind die grundlegenden Bausteine dafür.

Hooks verstehen

Multisite ist ein ziemlich fortgeschrittenes Thema. Bevor Sie versuchen, Multisite einzurichten, nehmen Sie sich etwas Zeit, um sich darüber zu informieren.

Discourse-Vorlagen verwenden pups; deren Regeln sind einfach und mächtig.

Jede Regel, die Sie ausführen, kann einen Hook definieren:

run:
  exec:
    cd: some/path
    hook: my_hook
    cmd:
      - echo 1

Später in Ihrem Container können Sie Regeln vor oder nach einem Hook einfügen:

hooks:
  before_my_hook:
    - exec: echo "I ran before"
  after_my_hook:
     - exec: echo "I ran after"

Im obigen Beispiel sehen Sie dann eine Ausgabe wie die folgende:

I ran before
1
I ran after

Sie können die Vorlagen in /var/discourse/templates durchlesen, um zu sehen, welche Hooks Ihnen zur Verfügung stehen.

Ändern Sie Ihren Standalone-Container, um den zweiten Site-Mandanten bereitzustellen

Ersetzen Sie den gesamten hooks-Abschnitt durch:

hooks:
  after_postgres:
     - exec: sudo -u postgres createdb b_discourse || exit 0
     - exec:
          stdin: |
            grant all privileges on database b_discourse to discourse;
          cmd: sudo -u postgres psql b_discourse
          raise_on_fail: false

     - exec: /bin/bash -c 'sudo -u postgres psql b_discourse <<< "alter schema public owner to discourse;"'
     - exec: /bin/bash -c 'sudo -u postgres psql b_discourse <<< "create extension if not exists hstore;"'
     - exec: /bin/bash -c 'sudo -u postgres psql b_discourse <<< "create extension if not exists pg_trgm;"'

  after_code:
    - exec:
        cd: $home/plugins
        cmd:
          - mkdir -p plugins
          - git clone https://github.com/discourse/docker_manager.git
  before_bundle_exec:
    - file:
        path: $home/config/multisite.yml
        contents: |
         secondsite:
           adapter: postgresql
           database: b_discourse
           pool: 25
           timeout: 5000
           host_names:
             - b.discourse.example.com

  after_bundle_exec:
    - exec: cd /var/www/discourse && sudo -H -E -u discourse bundle exec rake multisite:migrate

Es sind 4 Hooks im Spiel:

  1. after_postgres stellt sicher, dass nach der Installation von PostgreSQL eine zusätzliche Datenbank namens b_discourse mit den entsprechenden Berechtigungen und erforderlichen Erweiterungen erstellt wird.

  2. after_code stellt sicher, dass docker_manager in das Plugins-Verzeichnis geklont wird.

  3. before_bundle_exec stellt sicher, dass die Datei multisite.yml vorhanden ist (die festlegt, wo die Datenbanken zu finden sind).

  4. after_bundle_exec führt den benutzerdefinierten DB-Migrations-Task rake multisite:migrate aus – dies stellt sicher, dass alle Datenbanken auf dem neuesten Stand sind.

Hinweis zur Konfiguration

Das obige Beispiel kann bei Bedarf in einen Datencontainer / App-Container aufgeteilt werden. Führen Sie einfach den Hook after_postgres im Datencontainer und den Rest im Webcontainer aus.

Das obige Beispiel kann erweitert werden, um noch mehr Datenbanken bereitzustellen. Duplizieren Sie dazu die Aufrufe zum Erstellen von Datenbanken usw. und stellen Sie sicher, dass Sie zusätzliche Sites in multisite.yml hinzufügen.

Stellen Sie sicher, dass Sie den Knoten host_names in multisite.yml an den tatsächlichen Hostnamen anpassen, den Sie hosten möchten.

Wenn Sie außerdem HTTPS betreiben möchten, benötigen Sie einen Proxy vor der Site, um dies zu handhaben, da die integrierte Letsencrypt-Funktionalität in einem Multisite-Szenario nicht funktioniert.

71 „Gefällt mir“
How does multisite.yml look?
Multiple Forums in a Single Installation
How to create 1000 subcategories in a scalable way?
Multiple Discourses, multiple containers, one server
Pros and cons of multiple standalone containers vs one for multiple Discourse installs?
Success - New Multisite Install on Dedicated server using ServerPilot, Nginx and Apache
Multisite Installation
Will I need to start over with multisite configuration from standalone version?
Multiple Discourse Installs - Single Server
Starting a second Discourse forum on the same VPS
Pros and cons of a multisite installation
Installation wizard not appearing in multisite installs
Disabling/restricting user search
Sandbox and test discourse on host?
Multisite installation with seperated smtp emails
How do you set up multiple discourse forums on the same server?
Discourse for 3 different Countrys
Second discourse instance on the same server
Help me setup many websites on one VPS
Micro Forums: how many could I create?
Need proper documentation for multisite discourse with docker
Discourse multisite installation help with digitalocean
Remove sites from multisite config with Docker
Not receiving activation email for admin on multisite installation
Is it possible to totally hide members
Three sites in one setup
Can I log into multiple instances of discourse simultaneously?
Publishing multisite
Multisite viability - 2 read-only and 1 active
Multisite Config
Multiple communities on discourse?
Multitenat Dockerize Discourse
Need help with multisite configuration
Recover to one site from multisite
Adding an instance to multisite without rebuilding the container
How could I install another discourse on same server (docker)?
Install Discourse on Plesk / Ubuntu 14 without Docker
How to setup host mapping on a multi-site discourse instance
Totally Walled-Off Groups
Does discourse hosting use docker for all customer instances?
Tips for setting up a multi-subdomain Discourse instance with shared SSO?
Move from standalone container to separate web and data containers
Move from standalone container to separate web and data containers
Guidance on multi-site setup
Running multiple things on the same sever as my Pi (where Discourse is hosted)?
How extensible can I make my installation in terms of sub domains and restricting membership to them?
How can Admin login while Read-only mode is enabled on multisite?
One server for 2 Discourse communities?
One server for 2 Discourse communities?
Move from standalone container to separate web and data containers
I want to host hundreds of instances of Discourse
[mutlisite installation] pnpm permission error during rebuild
Setup Multisite Configuration with Let's Encrypt and no Reverse Proxy
Move from standalone container to separate web and data containers
Move from standalone container to separate web and data containers
Discourse instance stops running in every midnight
Feature proposal: Customizations based on primary group membership, a.k.a. tenancy 'lite'
Stable branch assets won't compile
Stable branch assets won't compile
Pull request for Wikis?
PAID Require Discourse expert for extreme customization
Add path to cookie
App.yml shared volumes for a two website setup
Contabo experience with Plesk, Webmin or other server-admin setup?
Using a launcher built docker image in docker-compose
Two standalone instances on one server?
Best approach for test and production instance of discourse
Are there other workarounds to not having category moderation such as multiple instances of the board?
WP SSO + Discourse Multisite
ActiveRecord::StatementInvalid: PG::UndefinedColumn: ERROR: column categories.search_priority does not exist
Multisite installation ... in subdirectories?
Multiple discourse instances in a single server
Integration with .NET MVC application for a SaaS platform
Multisite for small collection of sites for a family?
Hosting Plan Suggestion for 500 Concurrent Online Users
Avatar, Site Logos, and Cert Errors
Database access issues after upgrade v3.5.2 -> v3.6.0.beta2
Can I have two domains pointing towards the same IP address without redirect?
Multiple container setup problems
Installing on Kubernetes
How might we better structure #howto?
How to set redis DB ID in Docker container?
How can I host more than 1 Discourse forum on 1 VPS?
Multiple discourse installation on single droplet
Setup Multisite Configuration with Let's Encrypt and no Reverse Proxy
Docker image update: Redis 6 and 25% smaller image size
Pups::ExecError
Web-only - do I need a separate image for each container?
All users are visible in @mentions autocomplete list
Migrate from VPS to a Dedicated
Discourse Multisite – Nginx (Inside Docker) Only Serving Default Site
Two Discourse communities on the same VPS
How can I use different setting value for subdomain?
Will This Configuration Successfully Create a Second Discourse Instance (with Proxy)?
Pups::ExecError
Use CloudPanel to manage multiple sites with Discourse

12 Beiträge wurden in ein neues Thema verschoben: Verschiedene Multisite-Installationsfragen