Deploy Go on Your Own Server

Deploy Go web applications as minimal container images. Go compiles to a single static binary — your production image can be under 20 MB with near-instant startup.


Quickstart

From your project root, deploy with your preferred package manager:

npx @temps-sdk/cli up

Temps detects your go.mod, compiles your binary with go build, and runs it in a minimal Alpine container. Zero cold starts.


What Temps Handles Automatically

FeatureHow Temps handles it
Buildgo build -o app ./...
ImageMulti-stage build: builder + minimal Alpine
Image sizeTypically < 20 MB
HTTPSLet's Encrypt, auto-renewed
PortPORT env var injected, defaults to 8080
Health checksHTTP health check on your configured path
StartupNear-instant — static binary, no runtime

Dockerfile (optional)

Temps auto-generates a Dockerfile for Go projects. If you want full control, add your own:

# Build stage
FROM golang:1.22-alpine AS builder
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN go build -o app ./...

# Run stage
FROM alpine:latest
RUN apk add --no-cache ca-certificates
WORKDIR /app
COPY --from=builder /app/app .
EXPOSE 8080
CMD ["./app"]

Reading PORT from Environment

Make sure your server reads the PORT environment variable:

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

Managed PostgreSQL

Add a database from Project → Services → Add Service → PostgreSQL:

npx @temps-sdk/cli environments vars set DATABASE_URL "postgres://user:pass@host/db" -e production

Platform behavior

These rules apply to every app deployed on Temps, regardless of framework.

Health checks

After your container starts, Temps sends HTTP GET requests to verify it is healthy before routing traffic to it.

  • Path: / (the root of your application)
  • Success: 2 consecutive responses with a 2xx or 3xx status code
  • Timeout: 300 seconds (5 minutes) for the app to become healthy
  • Retry interval: every 5 seconds

Connection errors while the app is still starting are retried without penalty. If the app returns 4xx or 5xx errors for 60 consecutive seconds, the deployment fails. Customize the check by adding a .temps.yaml to your repository root:

.temps.yaml
health:
  path: /health
  status: 200
  interval: 30
  timeout: 5
  retries: 3

Auto-injected environment variables

Temps injects these variables into every deployment automatically:

VariableValueDescription
PORTResolved portThe port your app must listen on
HOST0.0.0.0Bind address
SENTRY_DSNAuto-generatedError tracking endpoint
TEMPS_API_URLYour Temps URLPlatform API endpoint
TEMPS_API_TOKENDeployment tokenAuthentication for Temps SDKs
OTEL_EXPORTER_OTLP_ENDPOINTYour Temps OTLP URLOpenTelemetry trace collection
OTEL_SERVICE_NAMEProject nameService identifier for traces

You do not need to configure these manually. They are available in process.env (Node.js), os.environ (Python), os.Getenv (Go), and the equivalent in other languages.


Next Steps

Was this page helpful?