Orthanc-python missing docker healthcheck

Hi! I am trying to implement a docker healthcheck with an Orthanc Python container, similarly to Orthan docker’s, but I couldn’t find the same for the Orthanc python version. I looked a bit through the github repos as well, but couldn’t find any info on that.

Would you have any tips? Or should I just use curl -f http://localhost:8042/changes or similar?

Dockerfile:

FROM  jodogne/orthanc-python:1.12.8

RUN apt-get update && \
    apt-get install -y --no-install-recommends \
    python3-venv \
    python3-dev \
    libpq-dev \
    gcc

RUN python3 -m venv /.venv

WORKDIR /etc/orthanc

COPY requirements.txt ./

RUN /.venv/bin/pip install --no-cache-dir -r requirements.txt
ENV PYTHONPATH=/.venv/lib64/python3.11/site-packages/

and in my current docker-compose.yaml:

  orthanc_ntrc:
    build:
      context: ./orthanc
      dockerfile: Dockerfile
    ...
    healthcheck:
      test: ["CMD", "curl", "-f", "-u", "user:userPassword", "http://localhost:8042/changes"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 40s

This shows “(unhealthy)” in docker ps.

Running that curl command outside the container in the terminal returns a json output, similar looking at it in a browser.

Thanks!

Hi

curl is actually not installed and therefore, the healhtcheck fails:

docker run -it  --entrypoint=bash -p 8048:8042 jodogne/orthanc-python
root@998a8b0b4fee:~# curl
bash: curl: command not found

So you can either install curl or include the same python file that we use in orthancteam/orthanc: orthanc-builder/docker/orthanc/test-aliveness.py at master · orthanc-server/orthanc-builder · GitHub

HTH,

Alain

1 Like

That worked, thanks! I copied that test-aliveness.py script in my Orthanc python directory, then in the docker-compose.yaml:

  orthanc_ntrc:
    build:
      context: ./orthanc
      dockerfile: Dockerfile
    ...
    volumes:
      - ./orthanc_ntrc/db:/var/lib/orthanc/db
      - ./orthanc_ntrc/storage:/var/lib/orthanc/storage
      - ./orthanc_ntrc/python:/etc/orthanc
    healthcheck:
      test: ["CMD", "python3", "/etc/orthanc/test-aliveness.py", "--user=user", "--pwd=password"]
      interval: 10s
      timeout: 5s
      retries: 3
      start_period: 15s

Now I get a great “healthy” status! :white_check_mark: