Admiral-Piett / goaws

AWS (SQS/SNS) Clone for Development testing
MIT License
770 stars 145 forks source link

Health endpoint available but unused #258

Closed peevees closed 4 months ago

peevees commented 1 year ago

saw that there is a health endpoint available (yes it doesn't do much currently) so i wondered why not have a health check registered in the dockerfile for it? It would mean that the container can be seen as unhealthy if it isn't responding with a 200 on that endpoint. (and the endpoint can be extended in the future to do more intricate checks)

something like:

# build image
FROM golang:alpine as build

WORKDIR /go/src/github.com/Admiral-Piett/goaws

COPY ./app/ ./app/
COPY ./go.mod .
COPY ./go.sum .

RUN ls -la
RUN CGO_ENABLED=0 go test ./app/...
RUN go build -o goaws app/cmd/goaws.go

# release image
FROM alpine

COPY --from=build /go/src/github.com/Admiral-Piett/goaws/goaws /goaws

COPY app/conf/goaws.yaml /conf/

EXPOSE 4100

HEALTHCHECK --interval=1s --timeout=3s --start-period=5s --retries=15 \
  CMD wget --no-verbose --tries=1 --spider http://localhost:4100/health || exit 1

ENTRYPOINT ["/goaws"]

your current base alpine already have wget installed currently, you can of course make sure it is installed during building of the Dockerfile by adding in the release image part RUN apk add --no-cache wget

Admiral-Piett commented 10 months ago

@peevees Good thinking - if it's there might as well use it! 😄 I'll have a look at this as soon as I can.

chrisdaly3 commented 6 months ago

I'll nab this one and take a go at it this weekend. seems straightforward enough 👍