Multisite configuration with Docker

docker

(Jay Pfaffman) #110

Hey, @sam. multisite.yml is no longer to be found. Is this by design?

Edit: It’s now in config/multisite.yml.production-sample in discourse, but not in discourse-docker.


Using Letsencrypt SSL in multi-site setup
Straightforward direct-delivery incoming mail
(Kloknibor) #111

Hi everybody!

I understand how pups work from the Readme.md and I understand most of the code but the part I can’t understand is the following part :

 before_bundle_exec:
    - file:
        path: $home/config/multisite.yml
        contents: |
         secondsite:
           adapter: postgresql
           database: b_discourse
           pool: 25
           timeout: 5000
           db_id: 2
           host_names:
             - b.discourse.example.com

I indeed can’t find the multisite.yml either in the docker install like @pfaffman suggested and the multisite.yml in the normal discourse github isn’t very clear to me. Since it contains the same data you see to send from app.yml to multisite.yml (<- might be totally wrong here) what does there need to be in the multisite.yml for this tutorail? Do you also need to add your first domain in there?

Thanks in advance!

Robin


(Leo) #112

@sam, Hi how can we access rails console for these different tenants? I want to query over my dataset over these tenants. thanks


(Sam Saffron) #113

RAILS_DB=dbname rails c


(Leo) #114

No success :stuck_out_tongue:

RAILS_DB=discourse2 rails c

ActiveRecord::Base.connection.current_database # => “discourse”


(Sam Saffron) #115

Are you on latest Discourse, it works just fine here:

/# RAILS_DB=livefit rails c
[1] pry(main)> ActiveRecord::Base.connection.current_database
=> "livefit"

What is the contents of multisite.yml for you? are you on latest tests-passed?


(Leo) #116

yeah, I’ve updated the branch recently

DiscourseUpdates.check_version.as_json
=> {“latest_version”=>“1.7.0.beta8”,
“critical_updates”=>false,
“installed_version”=>“1.7.0.beta8”,
“installed_sha”=>“e0803e1f915f7cf16bea65d56039cd35dc5fd93d”,
“installed_describe”=>“v1.7.0.beta8 +47\n”,
“missing_versions_count”=>0,
“git_branch”=>“tests-passed”,
“updated_at”=>“2016-12-01T11:24:01.485Z”}

=> multisite.yml
secondsite:
adapter: postgresql
database: discourse2
pool: 25
timeout: 5000
db_id: 2
host_names:
- forums.abc.com


(Sam Saffron) #117

Perhaps you should try this then…

RAILS_DB=secondsite rails c

(Leo) #118

Great! Thanks it worked. Probably I should rename ‘secondsite’ to database name.


(Felix Freiberger) #119

What is the correct way to initialize a new database in a multisite configuration?

This is what I’m doing so far:

#!/bin/bash
if [ $# -eq 0 ]
  then
    echo "No arguments supplied"
    exit 1
fi

echo "Creating database..."
sudo -u postgres createdb $1 || exit 0
echo "Granting privileges..."
sudo -u postgres psql $1 <<< "alter schema public owner to discourse;"
sudo -u postgres psql $1 <<< "grant all privileges on database \"$1\" to discourse;"
echo "Creating extensions..."
sudo -u postgres psql $1 <<< "create extension if not exists hstore;"
sudo -u postgres psql $1 <<< "create extension if not exists pg_trgm;"
echo "Running db:migrate..."
RAILS_DB=$1 cd /var/www/discourse && sudo -E -u discourse bundle exec rake db:migrate
echo "Done"

This typically results in a broken site because seeding failed. However, simply re-running the db:migrate step typically fixes it.


(Felix Freiberger) #120

Sorry to bump this, but… any chance to get some advice on this by a team member? :cry:


(Sam Saffron) #121

I would strongly recommend you run in a multicontainer environment if you are doing multisite, then use createdb to create the databases by entering the postgres container.


Contabo experience with Plesk, Webmin or other server-admin setup?
(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).


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?
#127

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

Hi,

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 ## ## - Pastebin.com 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?


Setting up Let’s Encrypt with Multiple Domains