Deploy a Go Gin App on Leapcell
Quickly deploy your Go app using the Gin framework on Leapcell in a few steps. Use our example app or your own.
1. Fork the Gin example on GitHub.
Here’s the main.go
file from that repo, which is borrowed from the official gin docs:
package main
import "github.com/gin-gonic/gin"
func main() {
r := gin.Default()
r.GET("/ping", func(c *gin.Context) {
c.JSON(200, gin.H{
"message": "hello leapcell",
})
})
r.Run() // listen and serve on 0.0.0.0:8080
}
2. Create a Service in the Leapcell Dashboard and connect your new repo.
Go to the Leapcell Dashboard and click the New Service button.
Then click Connect with GitHub
and select the forked repository.
3. Provide the following values during creation:
Field | Value |
---|---|
Runtime | Go (Any version) |
Build Command | go build -tags netgo -ldflags '-s -w' -o app |
Start Command | ./app |
Port | 8080 |
4. Access Your App:
Once deployed, you should see a URL like foo-bar.leapcell.dev
on the Deployment page. Visit the domain shown on the service page.
Continuous Deployments
Every push to the linked branch automatically triggers a build and deploy. Failed builds are safely canceled, leaving the current version running until the next successful deploy.
Learn more about Continuous Deployments.