Skip to content

Commit 170332a

Browse files
committed
fix: make health check compatible with slim base image
1 parent 9843742 commit 170332a

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@ LABEL org.opencontainers.image.authors="Joe Pitt <Joe.Pitt@joepitt.co.uk>" \
2222
VOLUME [ "/etc/serles" ]
2323
COPY configure.py /usr/local/sbin/configure.py
2424
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
25+
COPY healthcheck.py /usr/local/bin/healthcheck.py
2526
COPY gunicorn_config.py /opt/serles/gunicorn_config.py
2627
ENTRYPOINT [ "sh", "/usr/local/bin/entrypoint.sh" ]
27-
HEALTHCHECK --timeout=3s CMD [ "curl", "-f", "http://localhost:8000/" ]
28+
HEALTHCHECK --timeout=3s CMD [ "/opt/serles/bin/python3", "/usr/local/bin/healthcheck.py" ]
2829
RUN python3 -m venv /opt/serles &&\
2930
. /opt/serles/bin/activate &&\
3031
python3 -m pip install --quiet --no-cache-dir --upgrade pip setuptools &&\

healthcheck.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/usr/bin/env python3
2+
3+
"""Check if serles-acme is up"""
4+
5+
from sys import exit as sys_exit
6+
7+
from requests import get
8+
9+
if not get("http://127.0.0.1:8000/", timeout=3).ok:
10+
# signal unhealthy to the Docker Engine
11+
sys_exit(1)

0 commit comments

Comments
 (0)