File tree Expand file tree Collapse file tree 3 files changed +22
-2
lines changed Expand file tree Collapse file tree 3 files changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -48,10 +48,11 @@ RUN adduser --system --home /var/lib/sqld --uid 666 --gid 666 sqld
48
48
WORKDIR /var/lib/sqld
49
49
USER sqld
50
50
51
- COPY docker-entrypoint.sh /usr/local/bin
51
+ COPY docker-entrypoint.sh docker-healthcheck.sh /usr/local/bin
52
52
53
53
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
54
54
COPY --from=builder /target/release/sqld /bin/sqld
55
55
56
+ HEALTHCHECK --interval=2s CMD /usr/local/bin/docker-healthcheck.sh
56
57
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh" ]
57
58
CMD ["/bin/sqld" ]
Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ RUN apt update
24
24
25
25
COPY --from=builder /sqld/bin /bin/sqld
26
26
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
27
- COPY docker-entrypoint.sh /usr/local/bin
27
+ COPY docker-entrypoint.sh docker-healthcheck.sh /usr/local/bin
28
28
29
29
VOLUME [ "/var/lib/sqld" ]
30
30
@@ -35,5 +35,6 @@ WORKDIR /var/lib/sqld
35
35
36
36
EXPOSE 5001 8080
37
37
38
+ HEALTHCHECK --interval=2s CMD /usr/local/bin/docker-healthcheck.sh
38
39
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
39
40
CMD ["/bin/sqld"]
Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ SQLD_HTTP_LISTEN_ADDR=" ${SQLD_HTTP_LISTEN_ADDR:- " 0.0.0.0:8080" } "
5
+ SQLD_HTTP_LISTEN_ADDR=" ${SQLD_HTTP_LISTEN_ADDR//:/ \/ } "
6
+
7
+ exec 3<> " /dev/tcp/$SQLD_HTTP_LISTEN_ADDR "
8
+ echo -e " GET /health HTTP/1.1\r\nConnection: close\r\n\r\n" >&3
9
+ RESPONSE=$( cat < & 3)
10
+ exec 3< & - && exec 3>& -
11
+
12
+ if echo " $RESPONSE " | grep -q " HTTP/1.1 200 OK" ; then
13
+ exit 0
14
+ else
15
+ echo " Did not receive HTTP 200 response"
16
+ echo " $RESPONSE "
17
+ exit 1
18
+ fi
You can’t perform that action at this time.
0 commit comments