Deploy Go
Build and run a Go HTTP service with an explicit entry point and listening port.
Openstead detects Go projects from go.mod. Commit go.mod, go.sum, and the source required to build the application.
Bind the HTTP server
Use the runtime PORT variable and listen on all interfaces. A minimal server is:
package main
import (
"log"
"net/http"
"os"
)
func main() {
port := os.Getenv("PORT")
if port == "" {
port = "8000"
}
mux := http.NewServeMux()
mux.HandleFunc("/health", func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "text/plain")
w.WriteHeader(http.StatusOK)
_, _ = w.Write([]byte("ok"))
})
log.Fatal(http.ListenAndServe(":"+port, mux))
}For your production application, add appropriate request timeouts, graceful shutdown, and application routes.
Configure the service
For a repository with its main package in cmd/server:
| Setting | Value |
|---|---|
| Service type | Web Service |
| Build method | Railpack |
| Build command | go build -o bin/server ./cmd/server |
| Start command | ./bin/server |
| Port | 8000 |
| Health check path | /health |
If the main package is in the root, build . instead. Declare a compatible Go version in go.mod and inspect the toolchain reported by the build.
Custom native dependencies
Applications using CGO or platform libraries may need a Dockerfile. The runtime image must contain the native libraries required by the compiled binary; copying a dynamically linked binary into an unrelated minimal image can fail before the application logs anything.
If you deliberately build a static binary, confirm that every dependency supports that choice. Include CA certificates in the runtime when the application makes HTTPS calls.
Database connections and release work
Read the private database URL from an environment variable and configure a bounded connection pool. Use a dedicated migration executable or command in the paid pre-deploy phase if your application needs schema migrations.
A binary must be executable and available at the configured start path. If the service fails immediately, inspect the build output path, file permissions, native library requirements, and runtime logs before changing networking settings.