Installation on Docker - database "loomio_production" does not exist
Hi Everyone, I am trying to install Loomio following the instructions at https://github.com/loomio/loomio-deploy.
After a few false starts (completely new to Docker) I've managed to get this far;
Fresh install of Ubuntu 18.04
Install of Docker via Snap (including the instructions on setting new groups from here https://askubuntu.com/questions/907110/docker-snap-cannot-connect-to-the-docker-daemon-is-the-docker-daemon-running-o. I've also done the installation using a standard install of Docker https://docs.docker.com/install/linux/docker-ce/ubuntu/
Installed docker-compose & set permissions.
Cloned the github repo, tried various methods. Using 'sudo su' and just 'sudo', into /root/loomio-deploy and into /home/user/loomio-deploy
Skipped swap space (server has 16GB), and I get error using the script anyway;
dd: failed to open '/swapfile': Text file busy
mkswap: error: /swapfile is mounted; will not make swapspace
swapon: /swapfile: swapon failed: Device or resource busy
Set up env with no errors, configured SMTP
Initialised the database: 'docker-compose run app rake db:setup'. Some errors reported "PG::ConnectionBad: FATAL: database "loomio_production" does not exist"
Setup crontab no problems.
Started services: 'docker-compose up -d'.
When I try connect to the webservice on the host using localhost or using fqdn set up in /etc/hosts I get "500 Internal Server Error".
Obvious errors in docker-compose logs -d;
loomio-db | FATAL: database "loomio_production" does not exist
loomio-worker | rake aborted!
loomio-worker | ActiveRecord::NoDatabaseError: FATAL: database "loomio_production" does not exist
Any ideas what is causing the database to report missing?
Kind regards,
Stuart
Stuart North Wed 27 Feb 2019 8:02PM
Hi @robertguthrie I have to run docker compose as sudo. I get a lot of output from 'sudo docker-compose run app rake db:create'
https://pastebin.com/8v9MvhaK
And I'm still getting the same errors in the logs;
loomio-db | FATAL: database "loomio_production" does not exist
loomio-app | rake aborted!
loomio-app | ActiveRecord::NoDatabaseError: FATAL: database "loomio_production" does not exist
I get no errors from running the command "docker exec -ti loomio-db su - postgres -c 'createdb loomio_production'"
but I'm getting tons of new errors in the logs now https://pastebin.com/TvZkc6vi
loomio-worker | Warning: method update
already defined
loomio-worker | [Worker(host:d0e053ee4ed8 pid:7)] Starting job worker
loomio-worker | 2019-02-27T20:00:34+0000: [Worker(host:d0e053ee4ed8 pid:7)] Starting job worker
loomio-db | ERROR: relation "delayed_jobs" does not exist at character 566
loomio-db | STATEMENT: SELECT a.attname, format_type(a.atttypid, a.atttypmod),
loomio-db | pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod,
loomio-db | c.collname, col_description(a.attrelid, a.attnum) AS comment
loomio-db | FROM pg_attribute a
loomio-db | LEFT JOIN pg_attrdef d ON a.attrelid = d.adrelid AND a.attnum = d.adnum
loomio-db | LEFT JOIN pg_type t ON a.atttypid = t.oid
loomio-db | LEFT JOIN pg_collation c ON a.attcollation = c.oid AND a.attcollation <> t.typcollation
loomio-db | WHERE a.attrelid = '"delayed_jobs"'::regclass
loomio-db | AND a.attnum > 0 AND NOT a.attisdropped
loomio-db | ORDER BY a.attnum
loomio-db |
loomio-worker | [Worker(host:d0e053ee4ed8 pid:7)] Error while reserving job: PG::UndefinedTable: ERROR: relation "delayed_jobs" does not exist
loomio-worker | LINE 8: WHERE a.attrelid = '"delayed_jobs"'::regclass
loomio-worker | ^
loomio-worker | : SELECT a.attname, format_type(a.atttypid, a.atttypmod),
loomio-worker | pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod,
loomio-worker | c.collname, col_description(a.attrelid, a.attnum) AS comment
loomio-worker | FROM pg_attribute a
loomio-worker | LEFT JOIN pg_attrdef d ON a.attrelid = d.adrelid AND a.attnum = d.adnum
loomio-worker | LEFT JOIN pg_type t ON a.atttypid = t.oid
loomio-worker | LEFT JOIN pg_collation c ON a.attcollation = c.oid AND a.attcollation <> t.typcollation
loomio-worker | WHERE a.attrelid = '"delayed_jobs"'::regclass
loomio-worker | AND a.attnum > 0 AND NOT a.attisdropped
loomio-worker | ORDER BY a.attnum
loomio-worker | 2019-02-27T20:00:34+0000: [Worker(host:d0e053ee4ed8 pid:7)] Error while reserving job: PG::UndefinedTable: ERROR: relation "delayed_jobs" does not exist
etc
Robert Guthrie Wed 27 Feb 2019 8:14PM
no errors on createdb means you created the database. Re run the db:setup command to fix those relation missing errors.
Stuart North Wed 27 Feb 2019 8:18PM
ok, that looked good https://pastebin.com/GFR0YhxV
and loomio appears to be loading now
many thanks @robertguthrie
Stuart North Wed 27 Feb 2019 8:14PM
@robertguthrie although I'm no longer getting '500 Internal Server Error'.
It redirects to /dashboard but the page is completely blank
https://pastebin.com/KeaEEAWH
Robert Guthrie Fri 5 Apr 2019 8:29PM
If dashboard page is blank please open javascript console and read any browser errors
Naomi Tue 2 Apr 2019 8:46PM
Hi, I'm facing this same problem. Whether I do:
docker-compose run app rake db:create
or
docker-compose run app rake db:setup
The result is the same for each:
ActiveRecord::NoDatabaseError: FATAL: database "loomio_production" does not exist
Robert Guthrie Fri 5 Apr 2019 8:31PM
try
docker-compose run app createdb loomio_production
docker-compose run app rake db:setup
If that does not work you'll need to sudo to postgres user to createdb.
Let me know if it works and I'll update the docs either way.
Naomi Sat 6 Apr 2019 8:12PM
Thankyou @robertguthrie but I'm not having much luck. I am new to Docker, so perhaps it's something trivial.
root@vultr:~/loomio-deploy# docker-compose run app createdb loomio_production
Starting loomio-db ... done
Starting loomio-redis ... done
Error response from daemon: OCI runtime create failed: container_linux.go:348: starting container process caused "exec: \"createdb\": executable file not found in $PATH": unknown
Naomi Sat 6 Apr 2019 8:19PM
Is this what you meant by "su to postgres and createdb"? Because that also has not helped...
postgres@vultr:~/loomio$ createdb loomio_production
postgres@vultr:~/loomio$ exit
exit
root@vultr:~/loomio-deploy# docker-compose run app rake db:setup
Starting loomio-db ... done
Starting loomio-redis ... done
rake aborted!
ActiveRecord::NoDatabaseError: FATAL: database "loomio_production" does not exist
Robert Guthrie · Wed 27 Feb 2019 7:46PM
Hi @stuartnorth - try
docker-compose run app rake db:create
or if that fails then I'd be keen to know about it.Something like
docker exec -ti loomio-db su - postgres -c 'createdb loomio_production'
might work, but I worry it may have a permission error.Let me know.