From 68327b5660db5941d19f58cbaef9e5f4da96c011 Mon Sep 17 00:00:00 2001 From: Dirk Heilig Date: Mon, 17 Apr 2023 21:47:53 +0200 Subject: [PATCH] init --- Dockerfile | 14 ++++++++++++++ builder | 38 ++++++++++++++++++++++++++++++++++++++ supervisord.conf | 8 ++++++++ 3 files changed, 60 insertions(+) create mode 100644 Dockerfile create mode 100755 builder create mode 100644 supervisord.conf diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..7743337 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,14 @@ +FROM debian:11 +RUN apt-get update +RUN apt-get dist-upgrade +RUN apt-get install -y git apache2 rsync wget supervisor +WORKDIR /tmp +RUN wget https://github.com/gohugoio/hugo/releases/download/v0.111.3/hugo_extended_0.111.3_linux-amd64.deb +RUN dpkg -i hugo_*_linux-amd64.deb +RUN mkdir -p /var/lock/apache2 /var/run/apache2 /var/run/sshd /var/log/supervisor +COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf +COPY builder /usr/local/bin/builder + + +EXPOSE 80 +CMD ["/usr/bin/supervisord"] \ No newline at end of file diff --git a/builder b/builder new file mode 100755 index 0000000..3262551 --- /dev/null +++ b/builder @@ -0,0 +1,38 @@ +#!/usr/bin/env bash +set -e + +REPO="https://git.c3re.de/c3re/test-website.git" + +refresh() { + cd + + test -d site/.git || { + test -d site && rm -rf site + git clone --recursive "$REPO" site + + } + + cd site + git pull + # iterate over all branches and checkout that branch + for branch in $(git branch -a | grep remotes | grep -v HEAD); do + branch=${branch#remotes/origin/} + git checkout "$branch" + git pull + git reset --hard + hugo + mkdir -p /var/www/html/"$branch" + rsync -avz --delete public/* /var/www/html/"$branch"/ + + done + +} + +while true; do + sleep 60 & + + refresh + + wait + +done diff --git a/supervisord.conf b/supervisord.conf new file mode 100644 index 0000000..ab51c72 --- /dev/null +++ b/supervisord.conf @@ -0,0 +1,8 @@ +[supervisord] +nodaemon=true + +[program:builder] +command=/usr/local/bin/builder + +[program:apache2] +command=/bin/bash -c "source /etc/apache2/envvars && exec /usr/sbin/apache2 -DFOREGROUND" \ No newline at end of file