Raja's Exocortex

HealthChecks

HealthChecks can be easily hosted on docker the official docker image.

This config shows how to host a HealthChecks server using docker, using Postgresql 17 and Traefik for publishing the service.

File: Docker Compose

# Docker compose file to run healthecks.io locally
# Filename: docker-compose.yaml

name: hc-example-com

services:
  hc:
    image: healthchecks/healthchecks
    container_name: hc.example.com

    env_file:
        - .env

    mem_limit: 512M

    volumes:
      - ./conf/my-logo.png:/opt/healthchecks/static-collected/img/logo.png:ro

    depends_on:
      pg:
        condition: service_healthy

    labels:
      - com.centurylinklabs.watchtower.enable=true
      - traefik.enable=true
      - traefik.http.routers.hc.rule=Host(`hc.example.com`)
      - traefik.http.routers.hc.tls=true
      - traefik.http.routers.hc.tls.certresolver=lets-encrypt
      - traefik.http.routers.hc.service=hc
      - traefik.http.services.hc.loadbalancer.server.port=8000

  pg:
    image: postgres:16-alpine
    container_name: hc-db.example.com

    environment:
      - POSTGRES_DB=$DB_NAME
      - POSTGRES_PASSWORD=$DB_PASSWORD

    expose:
      - 5432

    mem_limit: 128M

    volumes:
      - ./pg-data:/var/lib/postgresql/data

    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U postgres"]
      interval: 30s
      timeout: 5s
      retries: 3

    labels:
      - com.centurylinklabs.watchtower.enable=true

File: .env

# ENV file for HealthChecks.io, see: https://healthchecks.io/docs/self_hosted_configuration/
# Set DB_PASSWORD and SECRET_KEY to a random string using
# openssl rand --hex 16

ALLOWED_HOSTS=hc.example.com

DB=postgres
DB_CONN_MAX_AGE=0
DB_HOST=pg
DB_NAME=hc
DB_USER=postgres
DB_PASSWORD=TODO_SET_TO_A_RANDOM_STRING
DEBUG=False

DEFAULT_FROM_EMAIL=noreply-hc@example.com
EMAIL_HOST=
EMAIL_HOST_PASSWORD=
EMAIL_HOST_USER=
EMAIL_PORT=587
EMAIL_USE_TLS=True
EMAIL_USE_VERIFICATION=True

MASTER_BADGE_LABEL=Mychecks
PING_BODY_LIMIT=10000

PROMETHEUS_ENABLED=True
REGISTRATION_OPEN=False

SECRET_KEY=TODO_SET_TO_A_RANDOM_STRING
SHELL_ENABLED=False

SITE_NAME=Example HC
SITE_ROOT=https://hc.example.com

Create a Super User Account

# Create the first superuser account
docker-compose exec -ti hc /opt/healthchecks/manage.py createsuperuser

Reference

  1. Self hosting using Docker: https://healthchecks.io/docs/self_hosted_docker/
  2. Config parameters for .env: https://healthchecks.io/docs/self_hosted_configuration/