Skip to content

Deploy a Go App

This guide explains how to deploy a Go application on a VPS, cloud, or dedicated server using TurboCloud (a tollkit based on Docker and Caddy as your web server and reverse proxy). Whether you’re running your application on AWS, DigitalOcean, Hetzner, Scaleway or a dedicated physical server, the steps remain largely the same.

Setting Up the Server

Create a new server on your cloud provider or local machine with a public IP address, SSH access from your development machine, and a fresh Ubuntu 22.04 installation. Ensure that ports 22, 80, and 443 are open. (Some cloud providers, like AWS, close ports by default; you’ll need to open them before deployment.)

If you’re looking for a new cloud provider, consider Hetzner, DigitalOcean, or OVH. These providers typically have ports open by default. OVH also offers affordable domain registration and free DNS management via API.

I will show you 2 options how you can deploy a Go app - with TurboCloud and manually (with Docker and Caddy).

Deploy with One Command and TurboCloud

If you don’t want to deploy manually or don’t have time to set up a deployment pipeline, you can deploy your Go application to any cloud provider or private server with a single command from your local repository using TurboCloud. TurboCloud is a tool that helps you deploy web projects from local folders or GitHub / Bitbucket repositories.

Prepare Your Go App for Deployment

If you deploy with TurboCloud, it will use a Dockerfile in the project's root directory. If you haven't Dockerfile yet, it's very simple to create it:

  • Create a file named Dockerfile in your project’s root directory.
  • Add the following content:
FROM golang:1.23

WORKDIR /usr/src/app

# Pre-copy/cache go.mod to pre-download dependencies, only re-downloading them in subsequent builds if they change
COPY go.mod go.sum ./
RUN go mod download && go mod verify

# Copy the application source code
COPY . .

# Build the application
RUN go build -v -o /usr/local/bin/app ./...

# Define the command to run the application
CMD ["app"]

Deploy from the Local Repository

  • On your development machine, navigate to the folder containing the project's code and run the deployment command (replace server_ip with the actual public IP of your server and service_port with the port number your app uses):
cd my_project
curl https://turbocloud.dev/deploy | bash -s -- -i server_ip -p service_port
  • Wait until the deployment script displays the URL of the deployed Go application.
  • Full documentation for all available parameters and detailed instructions can be found at turbocloud.dev/docs.

Deploy from GitHub or Bitbucket

  • SSH into your server (replace server_ip with the actual public IP of your server):
ssh root@server_ip
  • Run the setup command:
curl https://turbocloud.dev/setup | bash -s
  • Once installation is complete, start the TurboCloud TUI (Terminal User Interface), which functions similarly to standard applications on macOS, Linux, and other operating systems but can operate on servers without displays. Use the TUI to set up deployments with interactive guides:
turbocloud