Multisite configuration with Docker

(Felix Freiberger) #122

But createdb isn’t enough, the DB also needs to be seeded / migrated, right?

(Sam Saffron) #123

seeding and migrating is easy cause you already have a step for that. That is what multisite:migrate does.

(Felix Freiberger) #124

I think I had already tried running multisite:migrate from within the standalone container, and it didn’t work out – but I’m not sure about that anymore.

I’d really like to avoid having to run a multi-container setup as it doesn’t really have an advantage for me, and brings a lot of additional complexity (including having to migrate from my current setup).

(Jay Pfaffman) #125

One significant advantage, and why I think that it makes sense even for a single site, is that you can bootstrap from the command line without taking the site down for 5-15 minutes.

I think what’s wrong with your db:migrate is that it’s running for the main site, not the one you just created. Add RAILS_DB=secondsite before your rake. But the multisite:migrate should do it, I’d think (but I’m far from an expert).

1 Like
Contabo experience with Plesk, Webmin or other server-admin setup?
(Felix Freiberger) #126

Bootstrapping has become such a rare event (thanks to Docker Manager) that this simply isn’t a strong enough argument to convince me to spend some hours adding complexity :slight_smile:

Good catch – the variable I’m setting might not actually come through. I’ve moved it just before the bundle command and will report back the next time I create a multisite tenant. Thanks!

Contabo experience with Plesk, Webmin or other server-admin setup?

Some time ago I had time to configure multisite with 3 containers: data, web, and redis. All was working fine until one day I upgraded, and bam, something wrong happened and I had to revert to single site from backups.

Now I have a little time and wish to get this multisite setup running again. But this time, I want to clarify some things before I break stuff again :slight_smile:

  • the admin dashboard used to have a blue “upgrade” button linking to /admin/upgrade, somehow this one disappeared for me. Do you know how to make it appear again? Maybe that simple thing already taints my installation for split containers.
  • is the “button upgrade” still available in multisite mode then?
  • how would you setup to have a plugin that appears on one instance, but not the next? This would be useful for staging a plugin in production environment, or to add a site-specific plugin (e.g., a theme).
Contabo experience with Plesk, Webmin or other server-admin setup?
Contabo experience with Plesk, Webmin or other server-admin setup?
(Rafael dos Santos Silva) #128

All sites on a multisite install share the same plugins. If the plugin is broken all sites are affected.

(Fajfi) #129


I want to setup discourse configuration with 2 site (2 domain).

My configuration: [YAML] # this is the all-in-one, standalone Discourse Docker container template ## ## - I only get 1 site working - 2nd get redirection to 1st one (and ssl certificate problems), is there any bad in my config?

I thought that can be ssl problem and with commenting:

#  - "templates/web.ssl.template.yml"
#  - "templates/web.letsencrypt.ssl.template.yml"
#  - "443:443" # https

Discourse did not work with this changes (after rebuild). Even if I start fresh installation with this changes, it did not work on http (port 80).

So is there any bad multisite configuration with my file?

1 Like
Setting up Let’s Encrypt with Multiple Domains
(Erlend Sogge Heggen) #130

If you only need two sites then you are probably better off setting up two separate Discourse instances.

1 Like
(Fajfi) #131

It will be 3 or more in the future I think.
In two seperate instances you mean two containers with nginx reverse proxy/haproxy?

(Fajfi) #132

Ok, there is Cache problem with redirection. HTTP work but on second site I get error (500 on site):

[secondsite] Started GET "/" for **** at 2017-11-22 21:15:11 +0000
[secondsite] Processing by ListController#latest as HTML
[secondsite] Completed 500 Internal Server Error in 37ms (ActiveRecord: 11.8ms)
[secondsite] ActiveRecord::StatementInvalid (PG::UndefinedTable: 
ERROR:  relation "groups" does not exist
LINE 1: SELECT "groups"."id", "groups"."name" FROM "groups" 
: SELECT "groups"."id", "groups"."name" FROM "groups" ORDER BY 
 "groups"."name" ASC)
 /var/www/discourse/vendor/bundle/ruby/2.4.0/gems/rack-mini-profiler-0.10.5/lib/patches/db/pg.rb:90:in `async_exec'
 [secondsite] Started GET "/" for **** at 2017-11-22 21:15:12 +0000
 [secondsite] Processing by ListController#latest as HTML
 [secondsite] Completed 500 Internal Server Error in 4ms (ActiveRecord: 0.7ms)
 [secondsite] ActiveRecord::StatementInvalid (PG::UndefinedTable: 
 ERROR:  relation "groups" does not exist 
 LINE 1: SELECT "groups"."id", "groups"."name" FROM "groups" ORDER BY...
 : SELECT "groups"."id", "groups"."name" FROM "groups" ORDER BY "groups"."name" ASC)
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/rack-mini-profiler-0.10.5/lib/patches/db/pg.rb:90:in `async_exec'
(Jay Pfaffman) #133

I suspect that the second database didn’t get created.

(Fajfi) #134

I found base in psql:

b_discourse-# \dS
 pg_catalog | pg_prepared_xacts               | view  | postgres
 pg_catalog | pg_proc                         | table | postgres
 pg_catalog | pg_range                        | table | postgres
 pg_catalog | pg_replication_origin           | table | postgres
 pg_catalog | pg_replication_origin_status    | view  | postgres
 pg_catalog | pg_replication_slots            | view  | postgres
 pg_catalog | pg_rewrite                      | table | postgres
 pg_catalog | pg_roles                        | view  | postgres
 pg_catalog | pg_rules                        | view  | postgres
 pg_catalog | pg_seclabel                     | table | postgres
 pg_catalog | pg_seclabels                    | view  | postgres
 pg_catalog | pg_settings                     | view  | postgres
 pg_catalog | pg_shadow                       | view  | postgres
 pg_catalog | pg_shdepend                     | table | postgres
 pg_catalog | pg_shdescription                | table | postgres
 pg_catalog | pg_shseclabel                   | table | postgres
 pg_catalog | pg_stat_activity                | view  | postgres
 pg_catalog | pg_stat_all_indexes             | view  | postgres
 pg_catalog | pg_stat_all_tables              | view  | postgres
 pg_catalog | pg_stat_archiver                | view  | postgres
 pg_catalog | pg_stat_bgwriter                | view  | postgres
 pg_catalog | pg_stat_database                | view  | postgres
 pg_catalog | pg_stat_database_conflicts      | view  | postgres
 pg_catalog | pg_stat_replication             | view  | postgres
 pg_catalog | pg_stat_ssl                     | view  | postgres
 pg_catalog | pg_stat_sys_indexes             | view  | postgres
 pg_catalog | pg_stat_sys_tables              | view  | postgres
 pg_catalog | pg_stat_user_functions          | view  | postgres
 pg_catalog | pg_stat_user_indexes            | view  | postgres
 pg_catalog | pg_stat_user_tables             | view  | postgres
 pg_catalog | pg_stat_xact_all_tables         | view  | postgres
 pg_catalog | pg_stat_xact_sys_tables         | view  | postgres
 pg_catalog | pg_stat_xact_user_functions     | view  | postgres
 pg_catalog | pg_stat_xact_user_tables        | view  | postgres
 pg_catalog | pg_statio_all_indexes           | view  | postgres
 pg_catalog | pg_statio_all_sequences         | view  | postgres
 pg_catalog | pg_statio_all_tables            | view  | postgres
 pg_catalog | pg_statio_sys_indexes           | view  | postgres
 pg_catalog | pg_statio_sys_sequences         | view  | postgres
 pg_catalog | pg_statio_sys_tables            | view  | postgres
 pg_catalog | pg_statio_user_indexes          | view  | postgres
 pg_catalog | pg_statio_user_sequences        | view  | postgres
 pg_catalog | pg_statio_user_tables           | view  | postgres
 pg_catalog | pg_statistic                    | table | postgres
 pg_catalog | pg_stats                        | view  | postgres
 pg_catalog | pg_tables                       | view  | postgres
 pg_catalog | pg_tablespace                   | table | postgres
 pg_catalog | pg_timezone_abbrevs             | view  | postgres
 pg_catalog | pg_timezone_names               | view  | postgres
 pg_catalog | pg_transform                    | table | postgres
 pg_catalog | pg_trigger                      | table | postgres
 pg_catalog | pg_ts_config                    | table | postgres
 pg_catalog | pg_ts_config_map                | table | postgres
 pg_catalog | pg_ts_dict                      | table | postgres
 pg_catalog | pg_ts_parser                    | table | postgres
 pg_catalog | pg_ts_template                  | table | postgres
 pg_catalog | pg_type                         | table | postgres
 pg_catalog | pg_user                         | view  | postgres
 pg_catalog | pg_user_mapping                 | table | postgres
 pg_catalog | pg_user_mappings                | view  | postgres
 pg_catalog | pg_views                        | view  | postgres
(106 rows)

Any ideas?

(Jay Pfaffman) #135

Not really. Perhaps it didn’t get seeded and migrated.

(Fajfi) #136

I thought that this line is for this:

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

I used this command in app and secondsite works! Now only SSL to configure :slight_smile:

1 Like
(veblock) #137

How exactly did you fix the issue? I keep getting

I, [2017-12-22T09:20:11.912278 #15] INFO -- : > cd /var/www/discourse && su discourse -c 'bundle exec rake db:migrate'

rake aborted!

PG::ConnectionBad: could not connect to server: No such file or directory

 Is the server running locally and accepting

 connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

Same thing locally and on the remote server. Manually can access/enter data container and Postgres with no probs.

(Jay Pfaffman) #138

Hey, @mpalmer, this seems like the problem I am having.

(veblock) #139

Ok, finally got it figured out. For those struggling with mulitsite + multicontainer setup please note the sample in the first post is not complete. You do need host and password specified in your secondsite section

    - file:
        path: $home/config/multisite.yml
        contents: |
           adapter: postgresql
           database: b_discourse
           host: data
           password: <DiscourseUserPGPassword>
           pool: 25
           timeout: 5000
           db_id: 2

Hope that helps someone.

(Felix Freiberger) #140

After quite some time, I can report that this worked! :tada:

The correct order seems to be:

  1. Amend multisite.yml.
  2. Create and migrate the DB with my script above and @pfaffman’s bugfix.
  3. Restart the container.
(Brahn) #141

The difference is multisite vs multisite+multicontainer. If you are just running multiple sites in the same container then you don’t need the host/password.