# Deploy Gin

Gin is detected from your `go.mod` and runs as a Go container on port `8080`. The [generated image](/platform/deployments/builds#dockerfiles-generated-or-your-own) compiles the module and ships the binary.

## Serve it

Listen on the routed [port](/create/build-settings#port) - `PORT` is set to it:

```go
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](/platform/environment-variables#build-time-and-runtime) with `os.Getenv` at startup. `DATABASE_URL` from the [Credentials tab](/platform/databases/connect) 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](/create/scaling#min-instances). Go's scheduler handles high [concurrency](/create/scaling#concurrency) comfortably; the per-size caps are the practical limit.

## Related

- [Go](/platform/frameworks/go): The runtime's defaults for any Go app.
- [Connect an app](/platform/databases/connect): DATABASE_URL, TLS, per-environment databases.
- [Scaling](/create/scaling): Concurrency caps per size.
