With this project you can provision a Hetzner VPS with Dokploy pre-installed using Terraform.
What is Dokploy?
An open-source, self-hosted Platform-as-a-Service (PaaS) that simplifies application deployment, database management, and server configuration through a web UI and CLI.
Why this project?
By combining Terraform with Dokploy, you get:
- Infrastructure as Code: Reproducible server provisioning which you can include in your version control
- Easy Deployment: Use Dokploy's UI/CLI to manage your applications after initial setup
Additionally:
- Server hardening and added security: SSH is hardened and root login is disabled by default. Only clients with the configured SSH key can access the server. To skip this step, remove the remote-exec line that runs
ssh_init.shinmain.tf.
The VPS will be provisioned with the following settings (configurable in main.tf):
server_type = "cx23"
image = "docker-ce"
location = "fsn1"- Terraform installed
- Hetzner Cloud account with:
- Activated account
- IPv4 primary IP named "dokploy-ip"
- API token
- Optional: Firewall rules (add to
main.tfunderfirewall_ids)
Generate SSH keys for server provisioning and access:
mkdir -p ~/.ssh/dokploy
ssh-keygen -t ed25519 -C "dokploy" -f ~/.ssh/dokploy/id_ed25519The SSH keys will be stored in ~/.ssh/dokploy/ on your local machine.
Once you've acquired your Hetzner API token, store it in the root directory of this project:
echo "your-api-token-here" > hetzner-token.txtterraform initterraform fmt
terraform validate
terraform applyThis will:
- Create a new server on Hetzner Cloud
- Disable root user and apply SSH hardening
- Install Dokploy
Upon successful completion, you'll see:
hcloud_server.dokploy-manager (remote-exec): Congratulations, Dokploy is installed!
hcloud_server.dokploy-manager (remote-exec): Please go to http://<your-ip>:3000Note: Your server's firewall should expose port 3000 otherwise Dokploy will not be accessible.
To destroy all resources created by Terraform:
terraform destroyWarning: This will permanently delete your server and all data on it.
Note: If there's a problem with cleaning up the resource automatically, make sure to clean up the known hosts on your local machine and SSH key for this project under
Hetzner Console > Security > SSH keys.