diff --git a/Docker/nginx.conf b/Docker/nginx.conf new file mode 100644 index 000000000..4296563be --- /dev/null +++ b/Docker/nginx.conf @@ -0,0 +1,28 @@ +user www; +worker_processes auto; # it will be determinate automatically by the number of core + +error_log /var/log/nginx/error.log warn; +#pid /var/run/nginx/nginx.pid; # it permit you to use /etc/init.d/nginx reload|restart|stop|start + +events { + worker_connections 1024; +} + +http { + include /etc/nginx/mime.types; + default_type application/octet-stream; + sendfile on; + access_log /var/log/nginx/access.log; + keepalive_timeout 3000; + server { + listen 80; + root /www; + index index.html index.htm; + server_name localhost; + client_max_body_size 32m; + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root /var/lib/nginx/html; + } + } +} \ No newline at end of file diff --git a/Docker/run.sh b/Docker/run.sh new file mode 100644 index 000000000..2407c97c7 --- /dev/null +++ b/Docker/run.sh @@ -0,0 +1,4 @@ +#!/bin/bash +timestamp=`date +%Y/%m/%d-%H:%M:%S` +echo "Crond run at $timestamp" +tinystatus /tinystatus/checks.csv /tinystatus/incidents.txt > /www/index.html diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..23bf20734 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,23 @@ +FROM alpine:3.14.1 + +RUN apk update && apk add bash curl netcat-openbsd nginx busybox-initscripts + +EXPOSE 80 +ADD Docker/run.sh /run.sh +RUN mkdir -p /tinystatus/ +ADD tinystatus /usr/local/bin/tinystatus +RUN chmod +x /run.sh /usr/local/bin/tinystatus +ADD checks.csv /tinystatus/checks.csv +ADD incidents.txt /tinystatus/incidents.txt +RUN echo '* * * * * /run.sh > /var/log/run.log' > /etc/crontabs/root +RUN touch /var/log/run.log +RUN mkdir -p /run/nginx/ +RUN adduser -D -g 'www' www +RUN mkdir /www +RUN chown -R www:www /var/lib/nginx +RUN chown -R www:www /www +RUN mv /etc/nginx/nginx.conf /etc/nginx/nginx.conf.orig +ADD Docker/nginx.conf /etc/nginx/nginx.conf + +CMD [ "sh", "-c", "crond && nginx -g 'daemon off;'" ] + diff --git a/README.md b/README.md index b41ff8b20..8ff98c1ce 100644 --- a/README.md +++ b/README.md @@ -41,3 +41,21 @@ Command can be: There are also `http4`, `http6`, `ping4`, `ping6`, `port4`, `port6` for IPv4 or IPv6 only check. Note: `port4` and `port6` require OpenBSD `nc` binary. +## Docker + +Build the static webpage Docker Image (Image size is about 15.8 MB). +``` +docker build -t tinystatus . +``` + +Run the Docker Container. +``` +docker run -d -p 80:80 --name tinystatus tinystatus +``` + +Stop and remove the Docker Container + +``` +docker stop tinystatus && docker rm tinystatus +``` +