Browse Source

Add experimental Dockerfile and docker-compose.yml

pull/470/head
Pēteris Caune 4 years ago
parent
commit
98439623c5
No known key found for this signature in database GPG Key ID: E28D7679E9A9EDE2
9 changed files with 143 additions and 2 deletions
  1. +1
    -0
      CHANGELOG.md
  2. +22
    -0
      docker/Dockerfile
  3. +34
    -0
      docker/docker-compose.yml
  4. +18
    -0
      docker/uwsgi.ini
  5. +1
    -1
      templates/docs/configuring_prometheus.html
  6. +1
    -1
      templates/docs/configuring_prometheus.md
  7. +34
    -0
      templates/docs/self_hosted_docker.html
  8. +31
    -0
      templates/docs/self_hosted_docker.md
  9. +1
    -0
      templates/front/base_docs.html

+ 1
- 0
CHANGELOG.md View File

@ -11,6 +11,7 @@ All notable changes to this project will be documented in this file.
- Add Signal integration (#428)
- Change Zulip onboarding, ask for the zuliprc file (#202)
- Add a section in Docs about running self-hosted instances
- Add experimental Dockerfile and docker-compose.yml
## Bug Fixes
- Fix unwanted HTML escaping in SMS and WhatsApp notifications


+ 22
- 0
docker/Dockerfile View File

@ -0,0 +1,22 @@
FROM python:3.8
RUN useradd --system hc
ENV PYTHONUNBUFFERED=1
WORKDIR /opt/healthchecks
COPY requirements.txt /tmp
RUN \
pip install --no-cache-dir -r /tmp/requirements.txt && \
pip install uwsgi
COPY . /opt/healthchecks/
RUN \
rm -f /opt/healthchecks/hc/local_settings.py && \
DEBUG=False SECRET_KEY=build-key ./manage.py collectstatic --noinput && \
DEBUG=False SECRET_KEY=build-key ./manage.py compress
USER hc
CMD [ "uwsgi", "/opt/healthchecks/docker/uwsgi.ini"]

+ 34
- 0
docker/docker-compose.yml View File

@ -0,0 +1,34 @@
version: "3"
volumes:
db-data:
services:
db:
image: postgres:12
volumes:
- db-data:/var/lib/postgresql
environment:
- POSTGRES_DB=hc
- POSTGRES_PASSWORD=fixme-postgres-password
web:
build:
context: ..
dockerfile: docker/Dockerfile
environment:
- DEBUG=False
- DB=postgres
- DB_HOST=db
- DB_PORT=5432
- DB_PASSWORD=fixme-postgres-password
- [email protected]
- EMAIL_HOST=fixme-smtp-server.example.org
- EMAIL_HOST_USER=fixme-smtp-username
- EMAIL_HOST_PASSWORD=fixme-smtp-password
- SECRET_KEY=fixme-secret-key
- SITE_ROOT=http://localhost:8000
ports:
- 8000:8000
depends_on:
- db
command: bash -c 'while !</dev/tcp/db/5432; do sleep 1; done; uwsgi /opt/healthchecks/docker/uwsgi.ini'

+ 18
- 0
docker/uwsgi.ini View File

@ -0,0 +1,18 @@
[uwsgi]
master
die-on-term
http-socket = :8000
harakiri = 10
post-buffering = 4096
processes = 4
enable-threads
threads = 1
chdir = /opt/healthchecks
module = hc.wsgi:application
thunder-lock
disable-write-exception
static-map = /static=/opt/healthchecks/static-collected
hook-pre-app = exec:./manage.py migrate
attach-daemon = ./manage.py sendalerts
attach-daemon = ./manage.py sendreports --loop

+ 1
- 1
templates/docs/configuring_prometheus.html View File

@ -1,5 +1,5 @@
<h1>Configuring Prometheus</h1>
<p>Healthchecks.io supports exporting metrics and check statuses to
<p>SITE_NAME supports exporting metrics and check statuses to
<a href="https://prometheus.io/">Prometheus</a>, for use with <a href="https://grafana.com/">Grafana</a>.</p>
<p>You can generate the metrics export endpoint by going to your project settings
and clicking "Create API Keys." You will then see the link to


+ 1
- 1
templates/docs/configuring_prometheus.md View File

@ -1,6 +1,6 @@
# Configuring Prometheus
Healthchecks.io supports exporting metrics and check statuses to
SITE_NAME supports exporting metrics and check statuses to
[Prometheus](https://prometheus.io/), for use with [Grafana](https://grafana.com/).
You can generate the metrics export endpoint by going to your project settings


+ 34
- 0
templates/docs/self_hosted_docker.html View File

@ -0,0 +1,34 @@
<h1>Running with Docker</h1>
<p>In the Healthchecks source code, <a href="https://github.com/healthchecks/healthchecks/tree/master/docker">/docker/ directory</a>,
you can find a sample configuration for running the project with
<a href="https://www.docker.com">Docker</a> and <a href="https://docs.docker.com/compose/">Docker Compose</a>.</p>
<p><strong>Note: The Docker configuration is a recent addition, and, for the time being,
should be considered highly experimental</strong>.</p>
<p>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 also does not handle SSL
termination. If you plan to expose it to the public internet, make sure you put a
SSL-terminating load balancer or reverse proxy in front of it.</p>
<h2>Getting Started</h2>
<ul>
<li>Grab the Healthchecks source code
<a href="https://github.com/healthchecks/healthchecks">from the Github repository</a>.</li>
<li>Edit the <code>/docker/docker-compose.yml</code> file; add your SMTP credentials
and any other needed <a href="../self_hosted_configuration/">environment variables</a>.</li>
<li>
<p>Create and start containers:</p>
<div class="highlight"><pre><span></span><code>$ <span class="nb">cd</span> docker
$ docker-compose up
</code></pre></div>
</li>
<li>
<p>Create a superuser:</p>
<div class="highlight"><pre><span></span><code>$ docker-compose run web /opt/healthchecks/manage.py createsuperuser
</code></pre></div>
</li>
<li>
<p>Open <a href="http://localhost:8000">http://localhost:8000</a> in your browser and log in with
the credentials from the previous step.</p>
</li>
</ul>

+ 31
- 0
templates/docs/self_hosted_docker.md View File

@ -0,0 +1,31 @@
# Running with Docker
In the Healthchecks source code, [/docker/ directory](https://github.com/healthchecks/healthchecks/tree/master/docker),
you can find a sample configuration for running the project with
[Docker](https://www.docker.com) and [Docker Compose](https://docs.docker.com/compose/).
**Note: The Docker configuration is a recent addition, and, for the time being,
should be considered highly experimental**.
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 also does not handle SSL
termination. If you plan to expose it to the public internet, make sure you put a
SSL-terminating load balancer or reverse proxy in front of it.
## Getting Started
* Grab the Healthchecks source code
[from the Github repository](https://github.com/healthchecks/healthchecks).
* Edit the `/docker/docker-compose.yml` file; add your SMTP credentials
and any other needed [environment variables](../self_hosted_configuration/).
* Create and start containers:
$ cd docker
$ docker-compose up
* Create a superuser:
$ docker-compose run web /opt/healthchecks/manage.py createsuperuser
* Open [http://localhost:8000](http://localhost:8000) in your browser and log in with
the credentials from the previous step.

+ 1
- 0
templates/front/base_docs.html View File

@ -45,6 +45,7 @@
<li class="nav-header">Self-hosted</li>
{% include "front/docs_nav_item.html" with slug="self_hosted" title="Overview" %}
{% include "front/docs_nav_item.html" with slug="self_hosted_configuration" title="Configuration" %}
{% include "front/docs_nav_item.html" with slug="self_hosted_docker" title="Running with Docker" %}
<li class="nav-header">Reference</li>
<li><a href="{% url 'hc-docs-cron' %}">Cron syntax cheatsheet</a></li>


Loading…
Cancel
Save