How to add a docker healthcheck to self-hosted instance?

Hi there,

I am just setting up a self-hosted instance of image: gristlabs/grist:latest and would like to add a docker healthcheck, but the image does not seem to contain curl, wget or even nc so does anyone have any idea how else to add a healthcheck?

Hmm good point, we should probably throw in curl as a convenience. There should be a way to do it with node, which is available, perhaps something like:

node -e "require('http').get('http://localhost:8484/status', res => process.exit(res.statusCode === 200 ? 0 : 1))"

That should return a non-zero status if the get() throws an error or if it returns a result with a non-200 status code. It is a bit verbose though! Would definitely accept a PR adding curl to the regular docker image:

Sorry, I can’t help with PRs, I have no idea how that works but based on your code here is a sample workign healthcheck which can be added to a docker-compose.yml file:

    healthcheck:
      test: ["CMD", "node", "-e", "require('http').get('http://localhost:8484/status', res => process.exit(res.statusCode === 200 ? 0 : 1))", "> /dev/null 2>&1"]
      interval: 10s
      timeout: 5s
      retries: 3
      start_period: 30s
1 Like

Thanks for posting the CMD that worked for you @Ovi !