Configuración Multisite con Docker

:warning: Aunque la aplicación Discourse admite la configuración multisitio, esta es una configuración avanzada para administradores de sistemas. Si no sabe lo que está haciendo, no configure multisitio. El equipo de Discourse no puede ofrecer soporte para la configuración multisitio.

Si desea alojar varios dominios en una única configuración de Docker, necesitará una configuración multisitio. Estos son los elementos básicos para una.

Entender los hooks

La configuración multisitio es un tema bastante avanzado. Antes de intentar una implementación multisitio, dedique algo de tiempo a aprender sobre ellos.

Las plantillas de Discourse usan pups; sus reglas son sencillas y potentes.

Cada regla que ejecute puede definir un hook:

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

Más tarde, dentro de su contenedor, puede insertar reglas antes o después de un hook:

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

Así que en el ejemplo anterior verá una salida como la siguiente:

I ran before
1
I ran after

Puede leer las plantillas en /var/discourse/templates para ver qué hooks tiene disponibles.

Modificar su contenedor independiente para aprovisionar el tenant del segundo sitio

Reemplace la sección completa de hooks con:

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

Hay 4 hooks en juego:

  1. after_postgres asegura que después de instalar postgres se cree una base de datos adicional llamada b_discourse con los permisos apropiados y las extensiones requeridas.

  2. after_code asegura que docker_manager se descargue en el directorio de plugins.

  3. before_bundle_exec asegura que el archivo multisite.yml esté en su lugar (que define dónde encontrar las bases de datos).

  4. after_bundle_exec ejecuta la tarea personalizada de migración de la base de datos rake multisite:migrate — esto asegura que todas las bases de datos estén actualizadas.

Nota sobre la configuración

El ejemplo anterior se puede dividir en contenedor de datos / contenedor de aplicaciones si es necesario. Simplemente ejecute el hook after_postgres en el contenedor de datos y el resto en el contenedor web.

El ejemplo anterior se puede extender para aprovisionar aún más bases de datos. Para hacerlo, aprovisione más bases de datos duplicando las llamadas de creación de DB, etc., y asegúrese de agregar sitios adicionales en multisite.yml.

Asegúrese de modificar el nodo host_names en multisite.yml para que coincida con el nombre de host real que desea alojar.

Además, si planea usar HTTPS, necesitará un proxy delante del sitio para manejarlo, ya que la funcionalidad integrada de letsencrypt no funcionará en un escenario multisitio.

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

12 publicaciones se dividieron en un nuevo tema: Varias preguntas de instalación de multisitio