Prepare the requirements
- At least 1 GB of system memory
- A fresh installation of
Ubuntu 18.04/20.04/22.04
- A domain pointing to the server ip will allow to add git remotes
dokku.my-domain.com
. - A wildcard domain
*.dokku.my-domain.com
will allow access to apps via $APP.dokku.my-domain.com
.
Installation
1
2
| wget https://raw.githubusercontent.com/dokku/dokku/v0.27.5/bootstrap.sh;
sudo DOKKU_TAG=v0.27.5 bash bootstrap.sh
|
Post installation
Allow authorized ssh keys to access dokku too
1
| cat ~/.ssh/authorized_keys | dokku ssh-keys:add admin
|
Set global base domain
1
| dokku domains:set-global dokku.my-domain.com
|
Letsencrypt TLS certificates
dokku-letsencrypt
is the official plugin for dokku that gives the ability to automatically retrieve and install TLS certificates from [letsencrypt.org](https://letsencrypt.or During ACME validation, your app will stay available at any time.
1
| sudo dokku plugin:install https://github.com/dokku/dokku-letsencrypt.git
|
Set global email
1
| dokku config:set --global DOKKU_LETSENCRYPT_EMAIL=your@email.tld
|
Enable automatic certificate renewal
1
| dokku letsencrypt:cron-job --add
|
Postgres database setup
Installation
1
| sudo dokku plugin:install https://github.com/dokku/dokku-postgres.git postgres
|
Creating the service
1
| dokku postgres:create my-database
|
Expose the port
Expose a postgres service on custom host:port to have access from out world:
1
| dokku postgres:expose my-database 5432
|
You can now find the user/pass/post of the datbase this way:
1
| dokku postgres:info my-database
|
Deployment
Creating an app
1
| dokku apps:create my-app
|
Set env variables
1
| dokku config:set my-app JWT_SECRET=jwt-secret JWT_EXPIRES_IN=1d NODE_ENV=production ...
|
Link postgres database to the app
1
| dokku postgres:link my-database my-app
|
This will add the proper DATABASE_URL
to the env variables of my-app
.
Add a git remote
1
| git remote add dokku dokku@dokku.may-domain.com:my-app
|
Push to Dokku
Set the proxy port (for the Dockerised apps)
1
| dokku proxy:ports-add my-app http:80:3000
|
Enable Letsencrypt
1
| dokku letsencrypt:enable my-app
|
Done 🙂