Skip to content

Instantly share code, notes, and snippets.

@bradley
Last active November 7, 2017 20:42
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bradley/43e8b76575d68190be22826454e42229 to your computer and use it in GitHub Desktop.
Save bradley/43e8b76575d68190be22826454e42229 to your computer and use it in GitHub Desktop.
## Bare Bones
1. Create your droplet, adding the 1-click install dokku app and giving it at least 1GB memory which Dokku will need for deployment, then navigate to your server's IP and complete the process in the dokku form that will exist there. Also be sure you've followed the guide [here](https://gist.github.com/bradley/0c06d3f2d3c63b097ea5e27befd4beb3) to set up the various accounts youll need on your ubuntu server correctly before proceeding.
2. SSH into your droplet: `ssh root@droplet-ip`
3. Create your dokku app: `dokku apps:create app-name`
4. By default your app is located at myapp.mydomain.com. If you want your app to be accessible via the root domain, then just add the root domain as one of your app's domains. `dokku domains:add app-name mydomain.com`.
5. On your local machine, in your project’s Git repository, add your droplet as a remote: `git remote add dokku dokku@droplet-ip:app-name`
6. Dokku will start your node app itself by calling `nmp start` but if you want to modify that create a `Procfile` in the root of your project and define the web command like in this example: `web: node app.js`.
7. If you need environmental variables set for your service, ssh in as root and set them with: `dokku config:set app-name KEY=VALUE`
8. Once those changes are made you can deploy your code to the remote: `git push dokku master`. By default it’ll be auto-detected as a Node project, started, and have the given port exposed.
9. If you have trouble pushing on this step be sure your local ssh key is associated with the dokku account on your server by running the following `cat ~/.ssh/id_rsa.pub | ssh root@mydomain.com "sudo sshcommand acl-add dokku custom-identifier"`
## Postgres
1. From your server install the dokku postgres toolbelt. You definitely will want it. `dokku plugin:install https://github.com/dokku/dokku-postgres.git`
2. Create the database `dokku postgres:create app_database_name`
3. Link your app with your database `dokku postgres:link app_database_name app-name`
4. Expose your app: `dokku postgres:expose app_database_name`
5. Print connection info: `dokku postgres:info app_database_name`. This will output, in addition to other info, a `dsn` property which you can use to dissect the various connection details youll need to tell you app how to connect to your database, in the following format: `postgres://<db_username>:<db_password_for_username>@<db_host>:<db_port>/<app_database_name`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment