first commit

master
Dirk Heilig 2024-01-18 16:21:22 +01:00
commit cf5ee0cebc
3 changed files with 57 additions and 0 deletions

21
Dockerfile 100644
View File

@ -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

1
index.html 100644
View File

@ -0,0 +1 @@
<h1>Please wait a few seconds</h1>

35
starter 100755
View File

@ -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"