I have an express app (based on kyt-starter-universal) with postgresql database and I struggle to figure it out. Setting up Debian 8.6 and installing dokku was easy. After that:
sudo dokku plugin:install https://github.com/dokku/dokku-postgres.git postgres
dokku apps:create myapp
dokku postgres:create myapp-db
dokku postgres:link myapp-db myapp
And then I’m kinda lost. I need to dump sql data to my app container, so executed locally:
pg_dump -U postgres -Fc localapp-db > database.dump
Do I need to grant any privileges in advance to be able access it, like:
GRANT ALL PRIVILEGES ON DATABASE localapp-db TO dokku;
Next step: uploading it to my cloud and executed:
dokku postgres:import myapp-db < database.dump
Here things got ugly - it showed me bunch of errors and failed (hence my question about privileges). Tried it second time - no errors. I tried to check my db, but my knowledge only works to this point.
Tried dokku postgres:expose myapp-db
but I was unable to figure out how to connect from my local pgAdmin3 installation.
I’m not sure how to set my local app config. From this tutorial: I assume I need to use process.env.DATABASE_URL
?
Actual deploying is also a mystery to me. For example using public folder: AFAIK after pushing my git project do dokku container it will execute npm start
to build and start my app. But I am supposed to have user uploaded files there, how to ensure they won’t be lost on next deploy? Can I browse its content from the container?
Bonus: I still don’t have a domain name, when I’m setting dokku/nginx can I use the hostname I am supposed to have later (myapp-example.com), or I have to configure it later?
Sorry, this question is too long, but I am kinda frustrated after few days of failures.
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
postgres:expose
command as you did. You can then connect to the ip of the server and the credentials provided by thepostgres:info
command. Note that the exposed ip will also be available in that command.DATABASE_URL
env var for your application.I would definitely read through our docs, I’d say we cover many common use cases and (hopefully) the docs are well structured and easy to read. If you think you can clarify something, jut click the pencil icon on the sidebar of our documentation, or if you’re unclear, I recommend:
Good luck!