Skip to content

Commit

Permalink
add healthcheck
Browse files Browse the repository at this point in the history
  • Loading branch information
skrul committed Jan 12, 2025
1 parent 2e33ffb commit 1b6c2cd
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,18 @@ RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} GOARM=${GOARM} make buil
#RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} GOARM=${GOARM} go build -ldflags="-w -s" -o /go/bin/teslaBleHttpProxy main.go
RUN mkdir -p /go/bin/key

FROM scratch
FROM alpine:3.21

# Timezone data
COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo
ENV TZ=Europe/Berlin
#WORKDIR /app/
COPY --from=builder /go/bin/teslaBleHttpProxy /teslaBleHttpProxy
COPY --from=builder /go/bin/key /key
COPY healthcheck.sh /healthcheck.sh
RUN chmod +x /healthcheck.sh
EXPOSE 8080

HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 CMD /healthcheck.sh

ENTRYPOINT ["/teslaBleHttpProxy"]
13 changes: 13 additions & 0 deletions healthcheck.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/sh

THRESHOLD_BYTES=100000000

MEMORY_USAGE_BYTES=$(cat /sys/fs/cgroup/memory.current)

if [ $MEMORY_USAGE_BYTES -gt $THRESHOLD_BYTES ]; then
echo "Memory usage ($MEMORY_USAGE_BYTES) exceeds threshold ($THRESHOLD_BYTES)"
exit 1
else
echo "Memory usage OK: $MEMORY_USAGE_BYTES"
exit 0
fi

0 comments on commit 1b6c2cd

Please sign in to comment.