そんな人向け
ライブリロード対応だよ
準備
1.docker-compose.yml
docker-compose.yml
version: '3'
services:
app:
container_name: gin
image: golang:1.12.0-alpine
volumes:
- .:/go/src/app
command: >
sh -c "cd /go/src/app &&
apk update &&
apk add --no-cache git &&
go get -u github.com/codegangsta/gin &&
go get -u github.com/golang/dep/cmd/dep &&
dep init ||
dep ensure &&
gin -i run"
ports:
- 3001:3001
2.main.go
main.go
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": "pong",
})
})
r.Run()
}
起動
$ docker-compose up
確認
$ curl http://localhost:3001/ping
{"message":"pong"}
停止
$ docker-compose down