Documentation menu

Deploy Gin on Light Cloud - a compiled Go container on port 8080 with fast cold starts, ideal for scale to zero.

Deploy Gin

Gin is detected from your go.mod and runs as a Go container on port 8080. The generated image compiles the module and ships the binary.

Serve it#

Listen on the routed port - PORT is set to it:

r := gin.Default()
r.GET("/", func(c *gin.Context) { c.String(200, "up") })

port := os.Getenv("PORT")
if port == "" {
    port = "8080"
}
r.Run(":" + port) // binds 0.0.0.0

Configuration and database#

Read environment variables with os.Getenv at startup. DATABASE_URL from the Credentials tab works with pgx, database/sql, and GORM; keep sslmode=require.

Scaling#

A compiled Go binary cold-starts in well under a second - Gin apps are the happiest case for scale to zero. Go's scheduler handles high concurrency comfortably; the per-size caps are the practical limit.