Skip to content

Commit b616988

Browse files
committed
Fix ci healthcheck
1 parent 17a5454 commit b616988

File tree

6 files changed

+33
-26
lines changed

6 files changed

+33
-26
lines changed

backend/embed/acme.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
#!/usr/bin/bash
2-
3-
VER=0.0.0
1+
#!/usr/bin/env bash
2+
set -euf -o pipefail
43

54
echo "Given Args: ${*}"
65
echo

backend/embed/api_docs/components/HealthObject.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,7 @@
22
"type": "object",
33
"description": "HealthObject",
44
"additionalProperties": false,
5-
"required": [
6-
"version",
7-
"commit",
8-
"healthy",
9-
"setup",
10-
"error_reporting"
11-
],
5+
"required": ["version", "commit", "healthy", "setup", "error_reporting"],
126
"properties": {
137
"version": {
148
"type": "string",
@@ -36,6 +30,12 @@
3630
"type": "boolean",
3731
"description": "Will the application send any error reporting?",
3832
"example": true
33+
},
34+
"acme.sh": {
35+
"type": "string",
36+
"description": "Acme.sh version",
37+
"example": "v3.0.0",
38+
"minLength": 1
3939
}
4040
}
41-
}
41+
}

docker/Dockerfile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,14 @@ RUN mkdir -p /dist \
3535
# Final image
3636
#===============
3737

38-
FROM jc21/nginx-full:github-acme.sh AS final
38+
FROM jc21/nginx-full:github-no-acme AS final
3939

4040
COPY --from=gobuild /dist/server /app/bin/server
4141

42-
ENV SUPPRESS_NO_CONFIG_WARNING=1
43-
ENV S6_FIX_ATTRS_HIDDEN=1
42+
ENV SUPPRESS_NO_CONFIG_WARNING=1 \
43+
S6_FIX_ATTRS_HIDDEN=1 \
44+
CERT_HOME=/data/acme/
45+
4446
RUN echo "fs.file-max = 65535" > /etc/sysctl.conf
4547

4648
# s6 overlay

docker/dev/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM jc21/nginx-full:github-acme.sh-golang
1+
FROM jc21/nginx-full:github-no-acme-golang
22
LABEL maintainer="Jamie Curnow <[email protected]>"
33

44
SHELL ["/bin/bash", "-o", "pipefail", "-c"]

docker/rootfs/bin/healthcheck.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env bash
2+
set -euf -o pipefail
3+
4+
HEALTHY="$(curl --silent "http://127.0.0.1:3000/api" | jq --raw-output '.result.healthy')"
5+
6+
echo "Healthy: ${HEALTHY}"
7+
[ "$HEALTHY" = 'true' ] || exit 1

scripts/wait-healthy

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,28 @@ DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
55

66
if [ "$1" == "" ]; then
77
echo "Waits for a docker container to be healthy."
8-
echo "Usage: $0 docker-container"
8+
echo "Usage: $0 docker-container 30"
99
exit 1
1010
fi
1111

1212
SERVICE=$1
13-
LOOPCOUNT=0
14-
HEALTHY=
1513
LIMIT=${2:-90}
1614

1715
echo -e "${BLUE}${CYAN}Waiting for healthy: ${YELLOW}${SERVICE}${RESET}"
1816

19-
until [ "${HEALTHY}" = "healthy" ]; do
20-
echo -n "."
21-
sleep 1
22-
HEALTHY="$(docker inspect -f '{{.State.Health.Status}}' $SERVICE)"
23-
((LOOPCOUNT++))
17+
is_up() {
18+
docker exec "$SERVICE" /bin/healthcheck.sh
19+
}
2420

25-
if [ "$LOOPCOUNT" == "$LIMIT" ]; then
26-
echo ""
27-
echo ""
21+
i=0
22+
while ! is_up; do
23+
i=$((i + 1))
24+
if [ "$i" == "$LIMIT" ]; then
2825
echo -e "${BLUE}${RED}Timed out waiting for healthy${RESET}"
26+
docker logs --tail 50 "$SERVICE"
2927
exit 1
3028
fi
29+
sleep 1
3130
done
3231

3332
echo ""

0 commit comments

Comments
 (0)