Skip to content

Commit 5ca1409

Browse files
committed
add healthcheck
1 parent 2e33ffb commit 5ca1409

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

Dockerfile

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,19 @@ RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} GOARM=${GOARM} make buil
2222
#RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} GOARM=${GOARM} go build -ldflags="-w -s" -o /go/bin/teslaBleHttpProxy main.go
2323
RUN mkdir -p /go/bin/key
2424

25-
FROM scratch
25+
#FROM scratch
26+
FROM alpine:3.21
27+
2628
# Timezone data
2729
COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo
2830
ENV TZ=Europe/Berlin
2931
#WORKDIR /app/
3032
COPY --from=builder /go/bin/teslaBleHttpProxy /teslaBleHttpProxy
3133
COPY --from=builder /go/bin/key /key
34+
COPY healthcheck.sh /healthcheck.sh
35+
RUN chmod +x /healthcheck.sh
3236
EXPOSE 8080
37+
38+
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 CMD /healthcheck.sh
39+
3340
ENTRYPOINT ["/teslaBleHttpProxy"]

healthcheck.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/sh
2+
3+
THRESHOLD_BYTES=100000000
4+
5+
MEMORY_USAGE_BYTES=$(cat /sys/fs/cgroup/memory.current)
6+
7+
if [ $MEMORY_USAGE_BYTES -gt $THRESHOLD_BYTES ]; then
8+
echo "Memory usage ($MEMORY_USAGE_BYTES) exceeds threshold ($THRESHOLD_BYTES)"
9+
exit 1
10+
else
11+
echo "Memory usage OK: $MEMORY_USAGE_BYTES"
12+
exit 0
13+
fi

0 commit comments

Comments
 (0)