Skip to content

Instantly share code, notes, and snippets.

@rpereira

rpereira/Dockerfile

Last active Feb 15, 2020
Embed
What would you like to do?
Setup Docker for Go development with hot reload
---
version: "3.7"
services:
app:
build: .
image: hot-reloading-app
ports:
- "8080:8080" # Web Server
volumes:
- ./:/app
environment:
PORT: "8080"
FROM golang:latest
RUN mkdir /app
WORKDIR /app
ADD . /app
RUN go get github.com/githubnemo/CompileDaemon
RUN go get github.com/gin-gonic/gin
ENTRYPOINT CompileDaemon --build="go build main.go" --command=./main
package main
import "github.com/gin-gonic/gin"
func setupRouter() *gin.Engine {
r := gin.Default()
r.GET("/ping", func(c *gin.Context) {
c.JSON(200, gin.H{
"message": "pong",
})
})
return r
}
func main() {
r := setupRouter()
// listen and serve on 0.0.0.0:8080
r.Run()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment