Hetzner Cloud is one of the cheapest yet stable cloud VPS offerings on the market.

From this article you will learn how to set deploy a Django app to an Ubuntu VPS from Hetzner Cloud.

If you are looking for tutorial for another cloud provider checkout out one of these:

Table of contents

Requirements

  1. An application to deploy
  2. Appliku Account
  3. Hetzner Cloud Account

Django Application

You need to have your app pushed to a git repository. You can use GitHub, GitLab or any other custom git repository.

For easiest deployment your application should have:

  • a requirements.txt file in the root of the repository with all dependecies needed to run the app
  • the Procfile with commands to run your app. Look at the example here: https://gitlab.com/speedpycom/speedpycom-backend/-/blob/main/Procfile
  • respect to environment variables if needed. e.g. DATABASE_URL for database credentials.
  • DEBUG mode turned off for security reasons.

We have a full Django with Docker and Postgres Tutorial if you want to learn more, or you can check our SpeedPy.com SaaS boilerplate

Appliku Account

If you don't already have an Appliku Account create it by going here: https://app.appliku.com/

Click on "Add a server"

Pick a Custom Server:

Select this key, we will need it at server creation step.

Hetzner Account

If you don't already have an account head over to their site to sign up Hetzner Cloud. (this link gives you €20 in Hetzner cloud credits).

When you have the account, go to their cloud panel and create a project.

https://console.hetzner.cloud/projects

Click on the newly created project

Hetzner Server Parameters

Click on Add Server

Pick the region you prefer.

Then pick OS image: Ubuntu 22.04

Pick a server type.

Appliku supports both x86 and ARM servers. But your app's dependencies should be up to date in order to work on ARM server.

We recommend to pick ARM architecture for better performance and cost saving.

At the moment of writing this article, Hetzner offers ARM servers only in the Falkenstein Data Center.

While you can go with as small server as you want, we recommend to get at least 2 vCPUs and 1 GB RAM.

ARM servers start with 4GB RAM and 2 vCPUs

Networking: Appliku only supports servers with IPv4. You will not be able to add your server to Appliku with IPv6 only.

Scroll down to SSH Key section and click on "Add SSH Key"

Paste the SSH key provided by the Appliku Dashboard

Give a name to the key and select "Set as default key" (optionally), click Add SSH Key

Click "Create & Buy Now"

When the server is ready (green dot appears on the left) click on the server's IP address to copy it

Paste it into the IP field in Appliku Dashboard

And click Check credentials and add server

You will be brought to the server page. You will see that setup process is started. You can see Setup Logs for details of the process or errors if setup fails.

Server setup is complete:

Adding an application

Click on the "Applications" menu link

You will get to the Git Provider selection.

Creating application from GitHub

Select the "Setup Credentials" for GitHub.

You need to get a personal token from GitHub.

Go to this link to create a token: https://github.com/settings/tokens

Click on Generate new token -> Generate new token(Classic) Fill in the note, select expiration date, check the "repo" checkbox and "user:email"

And click "Generate token".

Copy the token from the next page.

Go back to Appliku dashboard and paste the GitHub Token, and click Test Credentials and Save

Status must change to "Active".

Click on the logo in top left corner to get back to your team and go to Applications again and create an app, select GitHub.

Fill the form with the app name, select the repository with your application, branch and select the server, click on "Create Application".

You will see your app has been created, but not yet deployed.

Creating application from GitLab

Alternatively if you use GitLab you should add credentials for GitLab and create an app from GitLab.

Go to Applications menu link, Click "Add Application" and Setup credentials for GitLab.

You need to create a Personal Access Token here: https://gitlab.com/-/profile/personal_access_tokens

Give the key a name, set or clear expiration date, select "api" checkbox and click "Create Personal Access token"

Copy the token and paste it in Appliku dashboard.

After you click "Test Credentials and Save" the Status should turn green and say "Active".

Click on the logo to go back to your team, go to Applications, Add Application and select GitLab

Give your application a name, pick repository and the branch, select the server and click "Create Application"

Setup the app

Databases

If your application needs a database, which Django apps need most of the time, you can click on the "Manage" in databases block and "Create Database"

Select a database type you need and your server to deploy the DB to, click "Create database"

Your database will start deploying, wait for the deployment status to become "deployed".

Go back to your app

You can see your database is in the list.

Environment variables and build settings

Click on the "Settings" link next to the application name.

Go to the "Environment Variables" tab

You can see that the DATABASE_URL is already added automatically from the database you created.

If you have a .env file you can use "Import from .env" button to paste variables.

Or click on "Add" button and add variables one by one.

Usually for Django app we need to add DJANGO_ALLOWED_HOSTS and DJANGO_SECRET_KEY.

Appliku provides a default host name for your application which is YOUR_APP_NAME+ '.applikuapp.com'

After you finished adding your variables click on "Save and Deploy"

You will see that the deployment started.

Go back to the application overview.

The "Deploy Now" button is grey because deployment is in progress and in the "Latest deployment" Block you can see the currently running deployment.

Click on "Deployment #1"

You can see the deployment log. Scroll down to see the most recent output.

After it finishes and reports the "exit_code: 0", which is success go back to your application overview

Click on "View Application"

It will open your application in a new window!