Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add code support for running HTTPSWatch in Docker #97

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
FROM alpine:latest
MAINTAINER Antonios A. Chariton <[email protected]>

# 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"]
32 changes: 32 additions & 0 deletions docker/nginx.conf
Original file line number Diff line number Diff line change
@@ -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;
}

}

}
13 changes: 13 additions & 0 deletions docker/periodic-checks.sh
Original file line number Diff line number Diff line change
@@ -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
7 changes: 7 additions & 0 deletions docker/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh

echo "Launching periodic checker..."
/bin/periodic-checks.sh &
echo "Done"
echo "Launching nginx..."
nginx -g "daemon off;"