Skip to content

Commit dabc655

Browse files
committed
Add healthcheck
1 parent a0fd920 commit dabc655

2 files changed

Lines changed: 15 additions & 4 deletions

File tree

.github/workflows/docker-test.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,26 @@ jobs:
3030
run: |
3131
docker build -t jeedom:bullseye --build-arg DEBIAN=bullseye --build-arg DATABASE=1 .
3232
- name: run jeedom:bullseye and check
33-
# build current image for bullseye and check it
33+
# run current image for bullseye and check it
3434
run: |
3535
docker run -p 80:80 -d --rm --name jeedom_bullseye jeedom:bullseye
36-
sleep 45
36+
until [ "`docker inspect -f {{.State.Health.Status}} jeedom_bullseye`" == "healthy" ]; do
37+
echo "waiting container to be healthy..."
38+
sleep 5;
39+
done;
3740
docker exec jeedom_bullseye php sick.php
3841
- name: Build jeedom:bookworm
3942
# build current image for bookworm
4043
run: |
4144
docker build -t jeedom:bookworm --build-arg DEBIAN=bookworm --build-arg DATABASE=1 .
4245
- name: run jeedom:bookworm and check
43-
# build current image for bookworm and check it
46+
# run current image for bookworm and check it
4447
run: |
4548
docker run -p 81:80 -d --rm --name jeedom_bookworm jeedom:bookworm
46-
sleep 45
49+
until [ "`docker inspect -f {{.State.Health.Status}} jeedom_bookworm`" == "healthy" ]; do
50+
echo "waiting container to be healthy..."
51+
sleep 5;
52+
done;
4753
docker exec jeedom_bookworm php sick.php
4854
4955
- name: Clean docker image

Dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ RUN echo >${WEBSERVER_HOME}/initialisation
6262
WORKDIR ${WEBSERVER_HOME}
6363
EXPOSE 80
6464
EXPOSE 443
65+
66+
# check if apache is running
67+
HEALTHCHECK --interval=1m --timeout=3s --retries=5 --start-period=10s --start-interval=5s \
68+
CMD curl -f http://localhost/ || exit 1
69+
6570
COPY --chown=root:root --chmod=550 install/OS_specific/Docker/init.sh /root/
6671
COPY --chown=root:root --chmod=550 install/bashrc /root/.bashrc
6772
CMD ["bash", "/root/init.sh"]

0 commit comments

Comments
 (0)