Skip to content

Deploy a Go App

What You’ll Need

  • A server with a public IP address, SSH access, and a fresh installation of Ubuntu 22.04. Not sure which cloud provider to use? Try DigitalOcean, Vultr, or Hetzner.
  • A Go app
  • (Optional) A custom domain

Deployment Steps

  • Create a server on your cloud provider with Ubuntu 22.04, public IP address and SSH access.
  • Create a Dockerfile
  • Deploy the project from a local folder or GitHub/Bitbucket

What You’ll Get

  • A deployed Go app without vendor lock-in
  • HTTPS with an auto-generated or custom domain
  • WAF with the default ruleset recommended by OWASP
  • Rate limiting
  • CI/CD if you deploy from GitHub or Bitbucket

Deploying a Go App

It doesn’t matter whether you want to deploy your Go app directly from your development machine or from GitHub/Bitbucket — you should create a Dockerfile before deploying:

  1. Create a Dockerfile in the project root with 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 a Go App from a Local Folder

You can deploy Go projects directly from a local folder on your development machine using TurboCloud:

  • If the project is a Git repository, TurboCloud uploads files tracked by Git (you can check which files will be uploaded using git ls-files --recurse-submodules). Don’t forget to add the Dockerfile with git add Dockerfile.

  • If you’re not using Git, all files inside the project folder will be uploaded.

Now everything is ready — let’s deploy:

  1. Run the command below in the root of your Go app (replace server_ip with your server’s actual IP and app_port with the correct port your Go app listens to):

    Terminal window
    curl https://turbocloud.dev/deploy | bash -s -- -i server_ip -p app_port

    To use a custom domain, add the -d parameter (make sure your domain’s A record points to the server’s IP):

    Terminal window
    curl https://turbocloud.dev/deploy | bash -s -- -i server_ip -p app_port -d yourdomain.com
  2. After deployment, you’ll receive an auto-generated URL to access your site. If you specified your own domain in step 1, you can use that instead.

  3. (Optional) Visit console.turbocloud.dev to manage and monitor deployments. You can add custom domains, set up load balancing across servers, and more.

  4. To redeploy, just run the same command again:

    Terminal window
    curl https://turbocloud.dev/deploy | bash -s -- -i server_ip

Deploy a Go App from GitHub / Bitbucket

  1. Push the Dockerfile and all necessary changes to your Git repository (GitHub and Bitbucket are supported).

  2. SSH into a server running Ubuntu 22.04 with a public IP address, and install TurboCloud (replace server_ip with your server’s actual IP; installation takes about a minute):

    Terminal window
    ssh root@server_ip
    curl https://turbocloud.dev/setup | bash -s
  3. After installation, visit console.turbocloud.dev to add and deploy your Go project. In the web console You can add custom domains, set up load balancing, and more.