Ok, I am working on learning how to run a separate data container, with the ultimate goal of being able to run multiple databases to support multi site. So I’m starting from the host directory
var/docker/sample/data.yml and I wonder if I can asks some general questions to see if I’m on track.
First, my understanding is that I should copy this file into my
/var/docker/containers folder, and then, when it is ready, I should run
./launcher rebuild data
If that’s correct I move on to understanding the file itself.
The first part of the file calls a number of templates:
templates: - "templates/cron.template.yml" - "templates/postgres.template.yml" - "templates/redis.template.yml" - "templates/sshd.template.yml"
templates/postgres.template.yml is going to set up the initial database. Am I correct so far?
Then jumping down to the
hooks in the same
hooks: after_postgres: - exec: stdin: | alter user discourse with password 'SOME_SECRET'; cmd: sudo -u postgres psql discourse raise_on_fail: false
Here I’m assuming that after the postgres db has been created, we are going to change the password for user ‘discourse’ to ‘SOME_SECRET’ Does that sound correct?
If so, then I imagine I can add the further commands about creating a second database directly after this, so that the whole
after_postgres looks like this:
hooks: after_postgres: - exec: stdin: | alter user discourse with password 'SOME_SECRET'; cmd: sudo -u postgres psql discourse raise_on_fail: false - 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;"'
Is there anything else I need to do before running this to set up two databases “discourse” and “b_discourse”?
If my file is ready, should I run
./launcher start data or first
./launcher bootstrap data and then
./launcher start data (I think probably the latter).
Thanks for your help.