Skip to content

Commit

Permalink
Add Docker health check and enhance status page
Browse files Browse the repository at this point in the history
  • Loading branch information
Julien Kernec'h committed Jul 24, 2018
1 parent 38041e8 commit 3dbf287
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ FROM alpine
RUN apk add --no-cache ca-certificates openssl
COPY --from=builder /go/go-http-proxy /bin/http_proxy

HEALTHCHECK --interval=5s --timeout=3s --retries=3 CMD curl -f http://localhost:8080 || exit 1

CMD ["/bin/http_proxy"]
6 changes: 5 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import (
"github.com/joho/godotenv"
)

var startTime time.Time

// GetPathMapping returns a key/value map of the PATH_MAPPING env var.
func GetPathMapping() map[string]string {
pathMappingValue := os.Getenv("PATH_MAPPING")
Expand Down Expand Up @@ -111,7 +113,9 @@ func Index(c *gin.Context) {
// Status returns the current time in a JSON object
func Status(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{
"time": time.Now().String(),
"name": "proxy",
"startedAt": startTime,
"uptime": time.Since(startTime).Seconds(),
})
}

Expand Down

0 comments on commit 3dbf287

Please sign in to comment.