@ -0,0 +1,5 @@ | |||
*.md | |||
*.yml | |||
.git/ | |||
.gitignore | |||
Dockerfile |
@ -0,0 +1,48 @@ | |||
FROM python:3-alpine | |||
# Caching layer with bash, tini, UWSGI and mysql / pg clients | |||
RUN set -ex \ | |||
&& apk add --no-cache mariadb-libs mariadb-client-libs postgresql-libs tini bash \ | |||
&& apk add --no-cache --virtual .build-deps \ | |||
gcc \ | |||
# uwsgi needs linux headers | |||
linux-headers \ | |||
# pip install needs py3 & musl dev | |||
python3-dev \ | |||
musl-dev \ | |||
mariadb-dev \ | |||
postgresql-dev\ | |||
&& pip3 install --no-cache-dir uwsgi mysqlclient psycopg2==2.6.2 \ | |||
&& apk del .build-deps | |||
# Add hc user | |||
RUN adduser -D -u 1000 hc | |||
# Install app requirements | |||
COPY requirements.txt /usr/src/app/ | |||
WORKDIR /usr/src/app/ | |||
RUN set -ex \ | |||
&& apk add --no-cache --virtual .build-deps \ | |||
gcc \ | |||
python3-dev \ | |||
musl-dev \ | |||
&& pip3 install braintree \ | |||
&& pip3 install --no-cache-dir -r requirements.txt \ | |||
&& apk del .build-deps | |||
# Copy application source | |||
COPY . /usr/src/app | |||
# Read settings from env vars | |||
RUN cp hc/local_settings.py.docker hc/local_settings.py | |||
# Pre-compile assets | |||
RUN set -ex \ | |||
&& ./manage.py collectstatic --no-input \ | |||
&& ./manage.py compress \ | |||
&& chown -R hc:hc /usr/src/app | |||
EXPOSE 9090 | |||
ENTRYPOINT [ "/usr/bin/tini", "--" ] | |||
CMD [ "/usr/src/app/bin/uwsgi-start.sh" ] |
@ -0,0 +1,21 @@ | |||
#!/bin/sh | |||
set -ex | |||
# wait for database connection to run migration | |||
while ! ./manage.py migrate 2>&1; do | |||
sleep 5 | |||
done | |||
#replace bash with uwsgi | |||
exec uwsgi --master \ | |||
--uid hc \ | |||
--gid hc \ | |||
--http-socket 0.0.0.0:9090 \ | |||
--processes 2 \ | |||
--threads 2 \ | |||
--chdir /usr/src/app \ | |||
--module hc.wsgi:application \ | |||
--enable-threads \ | |||
--thunder-lock \ | |||
--static-map /static=/usr/src/app/static-collected \ | |||
--attach-daemon "./manage.py sendalerts" |
@ -0,0 +1,30 @@ | |||
version: '2' | |||
services: | |||
hc: | |||
build: . | |||
# image: haswalt/docker-healthchecks | |||
image: quay.io/honestbee/healthcheck:latest | |||
ports: | |||
- "9090:9090" | |||
depends_on: | |||
- db | |||
environment: | |||
HEALTHCHECKS_EMAIL_HOST: mailhog | |||
HEALTHCHECKS_EMAIL_PORT: 1025 | |||
HEALTHCHECKS_DB: mysql | |||
HEALTHCHECKS_DB_HOST: db | |||
HEALTHCHECKS_DB_USER: root | |||
HEALTHCHECKS_DB_PASSWORD: pa55word | |||
HEALTHCHECKS_SITE_ROOT: http://localhost:9090 | |||
HEALTHCHECKS_DEBUG: 1 | |||
mailhog: | |||
image: mailhog/mailhog | |||
ports: | |||
- "8025:8025" | |||
db: | |||
image: mariadb | |||
environment: | |||
MYSQL_ROOT_PASSWORD: pa55word | |||
MYSQL_USER: hc | |||
MYSQL_PASSWORD: pa55word | |||
MYSQL_DATABASE: hc |
@ -0,0 +1,42 @@ | |||
""" | |||
Local settings for the HealthChecks app | |||
""" | |||
import os | |||
ALLOWED_HOSTS = ['*'] | |||
DEBUG = os.getenv('HEALTHCHECKS_DEBUG', False) | |||
HOST = os.getenv('HEALTHCHECKS_HOST', "localhost") | |||
SITE_ROOT = os.getenv('HEALTHCHECKS_SITE_ROOT', "http://localhost:9090") | |||
PING_ENDPOINT = SITE_ROOT + "/ping/" | |||
DEFAULT_FROM_EMAIL = os.getenv('HEALTHCHECKS_EMAIL_FROM', "[email protected]") | |||
EMAIL_HOST = os.getenv('HEALTHCHECKS_EMAIL_HOST', "localhost") | |||
EMAIL_PORT = os.getenv('HEALTHCHECKS_EMAIL_PORT', 25) | |||
EMAIL_HOST_USER = os.getenv('HEALTHCHECKS_EMAIL_USER', "") | |||
EMAIL_HOST_PASSWORD = os.getenv('HEALTHCHECKS_EMAIL_PASSWORD', "") | |||
if os.environ.get("HEALTHCHECKS_DB") == "postgres": | |||
DATABASES = { | |||
'default': { | |||
'ENGINE': 'django.db.backends.postgresql', | |||
'NAME': os.getenv("HEALTHCHECKS_DB_NAME", "hc"), | |||
'USER': os.getenv('HEALTHCHECKS_DB_USER', "postgres"), | |||
'PASSWORD': os.getenv('HEALTHCHECKS_DB_PASSWORD', ""), | |||
'HOST': os.getenv('HEALTHCHECKS_DB_HOST', "localhost"), | |||
'TEST': {'CHARSET': 'UTF8'} | |||
} | |||
} | |||
if os.environ.get("HEALTHCHECKS_DB") == "mysql": | |||
DATABASES = { | |||
'default': { | |||
'ENGINE': 'django.db.backends.mysql', | |||
'USER': os.getenv('HEALTHCHECKS_DB_USER', "root"), | |||
'PASSWORD': os.getenv('HEALTHCHECKS_DB_PASSWORD', ""), | |||
'NAME': os.getenv("HEALTHCHECKS_DB_NAME", "hc"), | |||
'HOST': os.getenv('HEALTHCHECKS_DB_HOST', "localhost"), | |||
'TEST': {'CHARSET': 'UTF8'} | |||
} | |||
} |