Deploy · Go
Go hosting for fast, small services.
Runex hosts Go apps from GitHub: it compiles your module into a single binary and runs it in an isolated container. Go's small binaries start fast, so new replicas come online in seconds.
- Single static binary
- net/http, Gin, Echo, Fiber
- Fast-starting replicas
- build
- go build · CGO_ENABLED=0
- binary
- /app · static
- listen
- :$PORT
- replicas
- 2 → autoscale
- url
- https://gateway.runex.cloud
Definition
Why is Go easy to host?
A Go program compiles to one self-contained binary. No runtime to install, and it starts almost instantly.
Go compiles your code and its dependencies into a single executable. With CGO_ENABLED=0, that binary runs on a minimal base image with nothing else installed.
On Runex, the binary runs in its own container and listens on the port from the PORT variable, behind HTTPS.
Small images and fast startup make Go a good fit for autoscaling: new replicas are ready almost as soon as they're scheduled.
How to deploy
How do you deploy a Go app on Runex?
Read PORT, commit go.mod, push.
-
You
Read PORT
Listen on ":" + os.Getenv("PORT").
-
You
Commit go.mod and go.sum
So builds are reproducible.
-
You
Connect the repo
Install the Runex GitHub App and pick the branch.
-
Runex
Build and run
Compiled binary in an isolated container.
Configuration
What does a minimal Go server look like on Runex?
Read the port from the environment and expose a health route.
package main
import ("net/http"; "os")
func main() {
http.HandleFunc("/health", func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("ok"))
})
port := os.Getenv("PORT")
if port == "" { port = "8080" }
http.ListenAndServe(":"+port, nil) // all interfaces
}
Need a specific Go version or a distroless image? Use a multi-stage Dockerfile: build with golang, run on a minimal base.
Avoid
What trips up Go deploys?
Ports, CGO, and missing module files.
- Listening on 127.0.0.1:8080 instead of :$PORT
- CGO enabled, so the binary needs libraries the base image lacks
- go.sum not committed, so the build can't verify modules
- Ignoring SIGTERM, so in-flight requests drop during deploys
FAQ
Go deploy questions
Short answers for your first deploy.
Which Go frameworks work on Runex?
Any Go HTTP server, including net/http, Gin, Echo, Fiber, and Chi. Runex runs the compiled binary and routes traffic to its port.
Do I need a Dockerfile to deploy Go on Runex?
No. Runex builds Go modules from your repo. Use a Dockerfile when you want a specific Go version or a distroless runtime image.
How do I handle graceful shutdown in Go?
Listen for SIGTERM and call server.Shutdown with a timeout so in-flight requests finish before the old container stops during a deploy.
Should I set CGO_ENABLED=0 for Go on Runex?
Yes, unless you need C libraries. A static binary runs on minimal base images and avoids missing-library errors at startup.
Next step
Deploy your Go service.
Connect your repo and get a live HTTPS URL on your first deploy. Free to start.
