Add healthcheck command
parent
2369c1d5c9
commit
de7af8cc7b
|
@ -5,6 +5,7 @@ COPY go.mod go.sum ./
|
|||
RUN go mod download
|
||||
COPY . ./
|
||||
RUN CGO_ENABLED=0 GOOS=linux go build -o /hats
|
||||
RUN CGO_ENABLED=0 GOOS=linux go build -o /healthcheck ./cmd/healthcheck/main.go
|
||||
|
||||
FROM builder as tester
|
||||
|
||||
|
@ -13,4 +14,5 @@ RUN go test -v
|
|||
FROM scratch
|
||||
|
||||
COPY --from=builder --chmod=755 /hats /hats
|
||||
COPY --from=builder --chmod=755 /healthcheck /healthcheck
|
||||
ENTRYPOINT [ "/hats" ]
|
|
@ -0,0 +1,22 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/go-resty/resty/v2"
|
||||
)
|
||||
|
||||
func main() {
|
||||
c := resty.New()
|
||||
resp, err := c.R().Get("http://127.0.0.1:8888/status")
|
||||
|
||||
if err != nil || !resp.IsSuccess() {
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if string(resp.Body()) == "OK" {
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
os.Exit(1)
|
||||
}
|
Loading…
Reference in New Issue