This guide explains how to deploy n8n, an extendable workflow automation tool, on a Dokku host. Dokku is a lightweight PaaS that simplifies deploying and managing applications using Docker.
Before proceeding, ensure you have the following:
- A working Dokku host.
- The PostgreSQL plugin installed on Dokku.
- (Optional) The Let's Encrypt plugin for SSL certificates.
Log into your Dokku host and create the n8n
app:
dokku apps:create n8n
-
Install the PostgreSQL plugin:
dokku plugin:install https://github.com/dokku/dokku-postgres.git postgres
-
Create a PostgreSQL service:
dokku postgres:create n8n
-
Link the PostgreSQL service to the app:
dokku postgres:link n8n n8n
Generate and set an encryption key for n8n:
dokku config:set n8n N8N_ENCRYPTION_KEY=$(echo `openssl rand -base64 45` | tr -d \=+ | cut -c 1-32)
Set the webhook URL for your n8n instance:
dokku config:set n8n WEBHOOK_URL=http://n8n.example.com
Set the domain for your app to enable routing:
dokku domains:set n8n n8n.example.com
Map the internal port 5678
to the external port 80
:
dokku ports:set n8n http:80:5678
You can deploy the app to your Dokku server using one of the following methods:
If your repository is hosted on a remote Git server with an HTTPS URL, you can deploy the app directly to your Dokku server using dokku git:sync
. This method also triggers a build process automatically. Run the following command:
dokku git:sync --build n8n https://github.com/d1ceward-on-dokku/n8n_on_dokku.git
This will fetch the code from the specified repository, build the app, and deploy it to your Dokku server.
If you prefer to work with the repository locally, you can clone it to your machine and push it to your Dokku server manually:
-
Clone the repository:
# Via HTTPS git clone https://github.com/d1ceward-on-dokku/n8n_on_dokku.git
-
Add your Dokku server as a Git remote:
git remote add dokku [email protected]:n8n
-
Push the app to your Dokku server:
git push dokku master
Choose the method that best suits your workflow.
Secure your app with an SSL certificate from Let's Encrypt:
-
Add the HTTPS port:
dokku ports:add n8n https:443:5678
-
Install the Let's Encrypt plugin:
dokku plugin:install https://github.com/dokku/dokku-letsencrypt.git
-
Set the contact email for Let's Encrypt:
dokku letsencrypt:set n8n email [email protected]
-
Enable Let's Encrypt for the app:
dokku letsencrypt:enable n8n
Congratulations! Your n8n instance is now up and running. You can access it at https://n8n.example.com.
For more information about n8n, visit the official documentation.