I've been trying to get Dokku, Ghost, and Postgres to work properly together but I cannot figure out what I am missing. Perhaps it simply Ghost doesn't support containerized postgres, or (more likely) I'm simply missing something in the config. My current config file looks like this:
database: {
database: {
client: 'pg',
connection: {
host : process.env.DB_HOST,
user : process.env.DB_USER,
password : process.env.DB_PASS,
database : process.env.DB_NAME,
port : process.env.DB_PORT,
charset : 'utf8'
}
},
logging: false
I've tried both the official beta Postgres plugin (https://github.com/dokku/dokku-postgres), as well as Flink's (https://github.com/Flink/dokku-psql-single-container) but both return connection errors. I picked apart the official plugin's URL and separated the host from the rest of the postgres connection string that is generated and got "ERROR: Your database configuration in config.js is invalid." This is the same line I get with Flink's, which is the config you see above.
I've pulled this from a tutorial here: robmcguinness . com/digitalocean-dokku-postgresql-and-ghost/ which is for previous versions, but I tried my best to correct for changes.
I know I can get sqlite to work, but I would much prefer Postgres to back the blog for the sake of making sure I could scale it if needed. If anyone notices anything I missed please let me know, I've toiled on this for hours before giving up and turning here for help.
For reference here is the censored output for those variables in the above config:
host : process.env.DB_HOST (postgres),
user : process.env.DB_USER (db_blog),
password : process.env.DB_PASS (a password),
database : process.env.DB_NAME (db_blog),
port : process.env.DB_PORT (5432)
The output of postgres for DB_HOST is because it is the container for the database. The official Postgres plugin didn't offer a user so I had to create one and then I used the created connection string to get the host info with was the same.
Thanks in advance,
Steve
The answer turns out to be simple. Using the official Postgres plugin you simply need to have
database: {
client: 'postgres',
connection: process.env.DATABASE_URL,
debug: false
},
as your database config in config.js. It wasn't initially apparent, to me, that all I needed to do was change the client from pg to postgres in order to use the database URL environment variable.