Boaz Poolman
Published on 4 May 2024
This tutorial covers everything from installing Dokku and creating a new app to configuring SSL with Let's Encrypt and deploying your app. Following these instructions, you can deploy and manage web applications, databases, and other services on your servers or cloud providers like DigitalOcean.
Dokku is a Docker-powered PaaS that helps you build and manage the lifecycle of applications. It is designed to be a lightweight and simple alternative to Heroku.
You can think of it as a self-hosted Heroku that you can deploy on your own infrastructure. With Dokku, you can easily deploy and manage web applications, databases, and other services on your own servers or cloud providers like DigitalOcean.
To start you'll have to SSH to the Ubuntu server. Once there you have to run the following commands:
For more information about Dokku installation please refer to their documentation here
Once you have Dokku installed you can create your first Dokku app!
To run Strapi succesfully you'll need to setup a couple of ENV variables. You can do that with the following command:
Please make sure to replace the "toBeModified" keys with actual secrets. If you need help generating these secrets you can use this handy tool
We'll use a Postgres database on the Dokku server as our database for Strapi.
Once you've created the database you'll have to link it to your Dokku app. You can do that by running the following;
Optionally you might want to expose your database to the outside world. That way you can use a database inspection tool like TablePlus to interact with it.
To expose your newly created Postgres database, run the following command;
For the purpose of keeping this tutorial simple I'm assuming you've allready setup the DNS of your domain to point to the Dokku server.
Once you've setup the domain you'll have to configure the proxy. You can do that by running the following three commands;
Depending on your Dokku version you might have to use the `dokku proxy:ports-add` instead.
Once all of that is done you are ready to deploy you Strapi app!
To learn how to deploy your Strapi app to a Dokku server automatically using Github Actions you can read my article about the topic:
To generate a Let's Encrypt SSL certificate we'll use the dokku-letsencrypt plugin. You can install that by running the following command
Once you have the plugin installed you can enable it for your app and it will automatically generate the certificates for the assosiated domains.
Boaz Poolman
Published on 4 May 2024