Deploy / Go

Deploy Go to Your Own Server

To deploy a Go service to your own server, install Temps on a Linux VPS and run up from the project root. Temps detects go.mod, compiles a static binary with CGO_ENABLED=0, runs it on a Debian slim image and serves it over automatic HTTPS. Your server only has to listen on the PORT Temps injects.

Last updated

Detection

Auto-detected from go.mod: Temps picks the Go preset, so up needs no flag.

How to deploy Go with Temps

Commands run on your machine unless they say otherwise. The CLI runs with bunx or npx.

  1. 1

    Install Temps on a Linux server

    On a VPS with at least 2 CPU cores and 4 GB of RAM, download the installer, read it, then run it. It installs Docker if needed, the Temps binary and its database, and asks how the console is reached: an sslip.io address or your own domain.

    curl -fsSL https://temps.sh/deploy.sh -o deploy.sh
    less deploy.sh
    bash deploy.sh
  2. 2

    Log in from your machine

    Point the CLI at your Temps console. It opens a browser to approve the login.

    bunx @temps-sdk/cli login https://console.example.com
  3. 3

    Listen on PORT

    Read the port Temps injects and bind on all interfaces.

    main.go
    port := os.Getenv("PORT")
    if port == "" {
        port = "8080"
    }
    log.Fatal(http.ListenAndServe(":"+port, nil))
  4. 4

    Pick a command in multi-binary repositories

    With several commands under cmd/, tell Temps which one to build.

    .temps.yaml
    build:
      build_command: go build -o /app/bin/app ./cmd/api
  5. 5

    Deploy Go

    From the project root, run up. If the directory isn't linked to a project yet, it walks you through creating one first. For a project created from a Git repository, pushes to the tracked branch deploy automatically.

    bunx @temps-sdk/cli up
  6. 6

    Create and link a PostgreSQL database

    Temps doesn't create a database for you. Create one, then link it to the project (or use Databases → Create database in the dashboard). Linking injects POSTGRES_URL plus POSTGRES_HOST, POSTGRES_PORT, POSTGRES_DB, POSTGRES_USER and POSTGRES_PASSWORD into the next deployment. It doesn't inject DATABASE_URL.

    bunx @temps-sdk/cli services create -t postgres -n my-go-app-db
    bunx @temps-sdk/cli services link --id <service-id> -p my-go-app
  7. 7

    Open the connection from POSTGRES_URL

    Read the injected URL with the driver you already use. Temps doesn't run migrations, so run them as a one-off step after the deploy.

    db, err := sql.Open("pgx", os.Getenv("POSTGRES_URL"))

How Temps builds and runs Go

Every app runs in a Docker container on your server, behind the Temps proxy. Before traffic switches to a new deployment, Temps health-checks it; if the check fails, the deployment is marked failed and the current version keeps serving.

Buildgo build -ldflags='-s -w' with CGO_ENABLED=0, a static binary
PackageThe main package in the repository root, or the single cmd/<name>/main.go
ImageMulti-stage: the binary is copied into a Debian slim runtime image
GoFrom the go line in go.mod; defaults to 1.23
PortTemps injects PORT

What works with Go on Temps

  • Static binary built with CGO_ENABLED=0
  • Debian slim runtime image
  • Near-instant startup
  • Root main package or a single cmd/<name>
  • Managed PostgreSQL you link
  • Health check before each cutover

Managed services for Go

Temps runs these services on your server. Create one, link it to the project, and its connection variables reach the next deployment. Set up managed services.

PostgreSQL

Injects POSTGRES_URL once linked

Environment variables for Go

Set your own with environments vars set or in the project settings; values are encrypted at rest.

VariableWhat it does
PORTSet by Temps
POSTGRES_URLInjected when PostgreSQL is linked

What it costs to self-host Go

Temps is free to self-host under MIT / Apache 2.0, with no per-seat fee and nothing metered, so hosting Go costs what the server costs. A Hetzner CX23 (2 shared vCPU, 4 GB RAM, 40 GB NVMe, 20 TB traffic) meets the minimum Temps needs and is €5.49/month excluding VAT, plus €0.50/month for an IPv4 address; Hetzner sells it in Germany and Finland only. Prices checked October 10, 2026.

TempsFree and open source (MIT / Apache 2.0)
ServerHetzner CX23: €5.49/month excluding VAT, plus €0.50/month for IPv4
What Go runsOne container running a single static binary, plus the managed PostgreSQL you link, on the same server.
ObservabilityWeb analytics, error tracking, session replay and uptime monitoring are included and run on the same server
Temps PremiumOptional: $399 per organisation per month for SAML SSO, SCIM, custom roles, approval gates and a tamper-evident audit log

For one to three production apps, the server guide recommends 4 vCPU and 8 GB RAM: a Hetzner CX33 is €8.49/month excluding VAT. Any Linux VPS that meets the minimum works; sizes and other providers are in Choosing a server. For what the same app costs on Fly.io, see Temps vs Fly.io.

Go on Temps: frequently asked questions

Which package does Temps build when my repository has several commands?

The main package in the root, or the single cmd/<name>/main.go. With several commands under cmd/, set build.build_command in .temps.yaml, for example go build -o /app/bin/app ./cmd/api.

Can I ship a smaller image than Debian slim?

Yes. Add your own Dockerfile with a scratch or distroless final stage; Temps uses it instead of generating one.

What if my Go app needs cgo?

The generated build sets CGO_ENABLED=0, so packages that need cgo, such as mattn/go-sqlite3, won't build. Use your own Dockerfile with cgo enabled, or a pure-Go alternative.

Included with every Temps project

Deployments, analytics, error tracking, session replay and uptime monitoring run in the same self-hosted platform, so your Go app doesn't need separate subscriptions for them.

Automatic HTTPS

Let's Encrypt certificates for every domain, issued and renewed for you.

Preview deployments

Turn on preview environments and each branch gets its own URL on your domain.

Web analytics

First-party analytics stored on your server. Add the React provider or a script tag.

Error tracking

Sentry-compatible: any Sentry SDK can report to the SENTRY_DSN Temps injects.

Session replay

Off by default. When on, it records the DOM with every input masked.

Uptime monitoring

HTTP monitors for your apps, with alerts through your notification channels.

Related guides

Deploy another framework

Deploy Go on a server you own

Temps is free and open source to self-host (MIT / Apache 2.0). You pay only for the server.