0
0
Fork 0
mirror of https://github.com/healthchecks/healthchecks.git synced 2025-04-07 14:15:34 +00:00
healthchecks_healthchecks/docker
2023-05-11 17:31:14 +03:00
..
.env.example Fix .env.example to have SMTPD_PORT undefined by default 2023-03-29 09:42:20 +03:00
docker-compose.yml Update Docker image's uwsgi.ini to use SMTPD_PORT env var 2023-02-07 13:38:05 +02:00
Dockerfile Add USE_GZIP_MIDDLEWARE env var which enables GZipMiddleware 2023-05-11 17:31:14 +03:00
README.md Add note about uwsgi running background tasks automatically 2023-04-07 13:35:27 +03:00
uwsgi.ini Fix uwsgi.ini to check for .gz files only in the CACHE dir 2023-05-11 17:03:18 +03:00

Running with Docker

This is a sample configuration for running Healthchecks with Docker and Docker Compose.

Note: For the sake of simplicity, the sample configuration starts a single database node and a single web server node, both on the same host. It does not handle TLS termination.

Getting Started

  • Copy /docker/.env.example to /docker/.env and add your configuration in it. As a minimum, set the following fields:

    • DEFAULT_FROM_EMAIL the "From:" address for outbound emails
    • EMAIL_HOST the SMTP server
    • EMAIL_HOST_PASSWORD the SMTP password
    • EMAIL_HOST_USER the SMTP username
    • SECRET_KEY secures HTTP sessions, set to a random value
  • Create and start containers:

    docker-compose up
    
  • Create a superuser:

    docker-compose run web /opt/healthchecks/manage.py createsuperuser
    
  • Open http://localhost:8000 in your browser and log in with the credentials from the previous step.

uWSGI Configuration

The reference Dockerfile uses uWSGI as the WSGI server. You can configure uWSGI by setting UWSGI_... environment variables in docker/.env. For example, to disable HTTP request logging, set:

UWSGI_DISABLE_LOGGING=1

Read more about configuring uWSGI in uWSGI documentation.

TLS Termination

If you plan to expose your Healthchecks instance to the public internet, make sure you put a TLS-terminating reverse proxy or load balancer in front of it.

Important: This Dockerfile uses UWSGI, which relies on the X-Forwarded-Proto header to determine if a request is secure or not. Make sure your TLS-terminating reverse proxy:

  • Discards the X-Forwarded-Proto header sent by the end user.
  • Sets the X-Forwarded-Proto header value to match the protocol of the original request ("http" or "https").

For example, in NGINX you can use the $scheme variable like so:

proxy_set_header X-Forwarded-Proto $scheme;

Pre-built Images

Pre-built Docker images, built from the Dockerfile in this directory, are available on Docker Hub. The images are built automatically for every new release.

The Docker images:

  • Support amd64, arm/v7 and arm64 architectures.
  • Use uWSGI as the web server. uWSGI is configured to perform database migrations on startup, and to run sendalerts, sendreports, and smtpd in the background. You do not need to run them separately.
  • Ship with both PostgreSQL and MySQL database drivers.
  • Serve static files using the whitenoise library.
  • Have the apprise library preinstalled.
  • Do not handle TLS termination. In a production setup, you will want to put the Healthchecks container behind a reverse proxy or load balancer that handles TLS termination.