master
Dirk Heilig 2023-04-17 21:47:53 +02:00
commit 68327b5660
3 changed files with 60 additions and 0 deletions

14
Dockerfile 100644
View File

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

38
builder 100755
View File

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

8
supervisord.conf 100644
View File

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