From cf5ee0cebca70b7bda40415c23719aaec22bdb37 Mon Sep 17 00:00:00 2001 From: Dirk Heilig Date: Thu, 18 Jan 2024 16:21:22 +0100 Subject: [PATCH] first commit --- Dockerfile | 21 +++++++++++++++++++++ index.html | 1 + starter | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+) create mode 100644 Dockerfile create mode 100644 index.html create mode 100755 starter diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..485d36b --- /dev/null +++ b/Dockerfile @@ -0,0 +1,21 @@ +FROM debian:12 +RUN apt-get update +RUN apt-get upgrade -y +RUN apt-get install -y git hugo nginx build-essential unar wget +RUN rm -rf /var/www/html +RUN mkdir -p /var/www/html + +WORKDIR /tmp +RUN wget https://github.com/tdewolff/minify/releases/download/v2.20.14/minify_linux_amd64.tar.gz +RUN unar minify*tar.gz +RUN mv minify_linux_amd64/minify /usr/local/bin + +ADD index.html /var/www/html/ +ADD starter /usr/local/bin/ + + +EXPOSE 80 +WORKDIR /repo + +RUN git clone https://git.c3re.de/c3re/c3re-website.git . +CMD /usr/local/bin/starter \ No newline at end of file diff --git a/index.html b/index.html new file mode 100644 index 0000000..7eb09e3 --- /dev/null +++ b/index.html @@ -0,0 +1 @@ +

Please wait a few seconds

\ No newline at end of file diff --git a/starter b/starter new file mode 100755 index 0000000..9f6a344 --- /dev/null +++ b/starter @@ -0,0 +1,35 @@ +#!/usr/bin/env bash +set -e +nginx -t +nginx -g 'daemon off;' & +nginx_pid=$! +function checkIsUpToDate() { + git fetch + git rev-list HEAD...origin/master --count | grep -q "^0$" && { + return 0 + } + return 1 +} + +function update() { + git reset --hard + git pull + make + mv /var/www/html /var/www/html-delme + mv dist/ /var/www/html + rm -rf /var/www/html-delme & + git reset --hard +} + +cd /repo +update +( + while true; do + sleep 15 + checkIsUpToDate && continue + update + done + +) & + +wait "$nginx_pid"