From 6699b9acbc1fb21dcf627a79106e4fc46d2dc43c Mon Sep 17 00:00:00 2001 From: DaKnOb Date: Thu, 6 Oct 2016 16:23:08 +0300 Subject: [PATCH] Add code support for running HTTPSWatch in Docker --- Dockerfile | 42 +++++++++++++++++++++++++++++++++++++++ docker/nginx.conf | 32 +++++++++++++++++++++++++++++ docker/periodic-checks.sh | 13 ++++++++++++ docker/run.sh | 7 +++++++ 4 files changed, 94 insertions(+) create mode 100644 Dockerfile create mode 100644 docker/nginx.conf create mode 100755 docker/periodic-checks.sh create mode 100755 docker/run.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..e0b249b --- /dev/null +++ b/Dockerfile @@ -0,0 +1,42 @@ +FROM alpine:latest +MAINTAINER Antonios A. Chariton + +# Install Python 3, pip, and lxml dependencies +RUN apk add --update python3 \ + python3-dev \ + build-base \ + libxml2 \ + libxslt \ + libxml2-dev \ + libxslt-dev \ + py-libxml2 \ + py-libxslt +RUN python3 -m ensurepip +RUN pip3 install --upgrade pip setuptools + +# Move everything inside the image +RUN mkdir /httpswatch +COPY . /httpswatch/. +WORKDIR /httpswatch + +# Install the required python modules +RUN pip3 install -r requirements.txt + +# Expose port 80 +EXPOSE 80 + +# Expose configuration volume +VOLUME ["/httpswatch/config/"] + +# Install nginx +RUN apk add nginx + +# Configure nginx +COPY ./docker/nginx.conf /etc/nginx/nginx.conf + +# Move Docker Scripts +COPY ./docker/run.sh /bin/run.sh +COPY ./docker/periodic-checks.sh /bin/periodic-checks.sh + +# Run nginx + periodic checker +CMD ["/bin/run.sh"] diff --git a/docker/nginx.conf b/docker/nginx.conf new file mode 100644 index 0000000..0421478 --- /dev/null +++ b/docker/nginx.conf @@ -0,0 +1,32 @@ +worker_processes 1; +pid /tmp/nginx.pid; + +events { + worker_connections 1024; +} + +http { + include mime.types; + default_type application/octet-stream; + + sendfile on; + + keepalive_timeout 65; + + server { + listen 80; + server_name localhost; + index index.html index.htm; + + location / { + root /httpswatch/out; + try_files $uri $uri.html /index.html; + } + + location /static/ { + root /httpswatch; + } + + } + +} diff --git a/docker/periodic-checks.sh b/docker/periodic-checks.sh new file mode 100755 index 0000000..c77645d --- /dev/null +++ b/docker/periodic-checks.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +export SLEEP=86400 + +echo "Periodic Checker launched!" +while :; do + echo "Checking for all websites on $(date)..."; + ./check_https.py; + echo "Done checking on $(date)."; + echo "Sleeping for $SLEEP seconds..."; + sleep $SLEEP; + echo "Done!" +done diff --git a/docker/run.sh b/docker/run.sh new file mode 100755 index 0000000..b857ea7 --- /dev/null +++ b/docker/run.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +echo "Launching periodic checker..." +/bin/periodic-checks.sh & +echo "Done" +echo "Launching nginx..." +nginx -g "daemon off;"