TurboCloud Docs Handbook

Deploy Node.js on Hetzner with a Custom Domain

Quick Start

In this guide, I will show how to deploy a Node.js project on Hetzner with TurboCloud—a deployment toolkit that helps deploy web projects from local folders and Git repositories with one command. TurboCloud is free to use with any non-commercial projects without limits; however, to deploy commercial projects, you should purchase a lifetime license ($90, one-time payment).

For this guide, you need just two things:

Start a new server on Hetzner with a public IPv4 address, Ubuntu 22.04, and SSH access from your local machine. Then, in the root folder of your project on your local machine, run the following command (replace server_public_ip with the IP of your server):

cd folder_with_project
curl https://turbocloud.dev/deploy | bash -s -- -i server_public_ip

For example, if your server’s IP address is 121.41.56.20, the command will look like this:

curl https://turbocloud.dev/deploy | bash -s -- -i 121.41.56.20

If everything goes well, your Node.js project will be deployed to Hetzner, and you’ll see an automatically generated URL in the console that you can use to access your project.

How to Use a Custom Domain

If you want to use a custom domain, add the -d parameter (omit https://, http://, ws://, or wss://). Ensure the domain's A record is correctly pointed to your server's IP address. For example:

curl https://turbocloud.dev/deploy | bash -s -- -i server_public_ip -d your_domain.com

Full Guide

TurboCloud is a deployment toolkit that automates the deployment of Node.js projects to Hetzner servers. It eliminates the need to create additional accounts and simplifies cloud provisioning by following best practices. These include protecting public projects with HTTPS, setting up VPNs for inter-server communication, establishing CI/CD pipelines, and much more.

  1. Set Up a Hetzner Cloud Server:

    • Create an account or log in at Hetzner. Note: Hetzner manually checks almost all new accounts, which is why it could take days to create a new account. If you want to start deploying now and don’t have a Hetzner account, try DigitalOcean or Vultr. TurboCloud works with almost any cloud provider.
    • Navigate to Project Name -> Servers and click Add Server.
    • Choose:
      • A data center location
      • Ubuntu 22.04 as the OS
      • A server type
      • IPv4 enabled
      • Your SSH key for server access
    • Assign any name to the server.
    • Click Create and Buy Now.
    • Wait for the server to become online in the Hetzner console.

    You can deploy multiple projects on a single server using TurboCloud, as long as sufficient resources are available.

  2. Prepare Your Node.js Project:

    • To deploy a Node.js project on Hetzner, you need a Dockerfile in the root folder of your project. Don’t worry if you have zero experience with Dockerfiles; all you need to do is create a file named Dockerfile in your project’s root directory with the following content (change FROM node:22-alpine if you need another Node.js version, and change CMD ["node", "index.js"] if your Node.js app should start with another JavaScript file—for example, CMD ["node", "app.js"]):
      # Replace the line below if you need another Node.js version
      FROM node:22-alpine
      
      # Set the working directory
      WORKDIR /usr/src/app
      
      # Copy package.json and package-lock.json to the container
      COPY package*.json ./
      
      # Install dependencies
      RUN npm install
      
      # Copy the rest of the application source code to the container
      COPY . .
      
      # Expose port 3000
      EXPOSE 3000
      
      # Define environment variable
      ENV NODE_ENV=production
      
      # Command to run the application
      CMD ["node", "index.js"]
                              
    • If you want to connect a custom domain to this Node.js app, you should set the A record of your domain or subdomain to point to the public IP address of the server where you plan to deploy.
  3. Deploy Your Project from the Local Folder:

    • In the root folder of the project on your local machine, run the following command (replace server_public_ip with the IP of your server): cd folder_with_project
      curl https://turbocloud.dev/deploy | bash -s -- -i server_public_ip

      For example, if your server’s IP address is 121.41.56.20, the command will look like this:

      curl https://turbocloud.dev/deploy | bash -s -- -i 121.41.56.20
    • If you want to use a custom domain, add the -d parameter (omit https://, http://, ws://, or wss://). Ensure the domain's A record is correctly pointed to your server's IP address. For example: curl https://turbocloud.dev/deploy | bash -s -- -i server_public_ip -d your_domain.com

How TurboCloud Deploys Node.js Projects


Summary

At this stage, your Node.js project should be online and accessible at the URL displayed in the console. Feel free to reach out to us if you have questions or encounter issues at hey@turbocloud.dev.