Gin 项目可以轻松部署在任何云提供商上。
Render
Render 是一个原生支持 Go 的现代化云平台,并支持全托管 SSL、数据库、不停机部署、HTTP/2 和 websocket。
参考 Render Gin 项目部署指南。
Deploy a Go Gin Web Server
This is a sample Go web server powered by the Gin web framework. You can use it as a starting point for deploying your own Go web apps on Render.
The sample app is based on Gin’s realtime chat example, and is available at https://go-gin.onrender.com.
The app uses server-sent events (SSEs) to broadcast messages.
Deployment
Fork render-examples/go-gin-web-server on GitHub.
Create a new Web Service on Render, and give Render permission to access your new repo.
Select Go for the environment and use the following values during creation:
Build Command: ./build.sh
Here are the contents of the build script:
#!/usr/bin/env bash
go get -u github.com/gin-gonic/gin
go get -d -v github.com/dustin/go-broadcast/...
go get -d -v github.com/manucorporat/stats/...
go build -o ./app main.go rooms.go routes.go stats.go
It’s simply executing commands needed to build and deploy the web server on every push to your repo.
Start Command: ./app
This will start the app executable compiled during build.
That’s it! Your Go, Gin, and SSE powered web server will be available on your onrender.com URL in the dashboard as soon as the build finishes.
Google App Engine
GAE 提供了两种方式部署 Go 应用。标准环境,简单易用但可定制性较低,且出于安全考虑禁止 syscalls。灵活环境,可以运行任何框架和库。
前往 Go on Google App Engine 了解更多并选择你喜欢的环境。