new static server and new zola

This commit is contained in:
dockeradm
2025-03-08 03:20:18 +01:00
parent 46b383d2e7
commit af07ba8243
3 changed files with 63 additions and 13 deletions
+3 -2
View File
@@ -8,8 +8,9 @@ FROM joseluisq/static-web-server:2-debian
RUN apt update && apt upgrade -y && \
apt install -y git openssh-client bash curl make wget sysvinit-utils && \
apt-get clean && apt-get autoremove -y && rm -rf /var/lib/apt/lists/*
RUN wget https://github.com/barnumbirr/zola-debian/releases/download/v0.17.2-1/zola_0.17.2-1_amd64_bullseye.deb && \
dpkg -i zola_0.17.2-1_amd64_bullseye.deb && rm zola_0.17.2-1_amd64_bullseye.deb
ARG ZOLAVERSION="0.20.0-1"
RUN wget https://github.com/barnumbirr/zola-debian/releases/download/v${ZOLAVERSION}/zola_${ZOLAVERSION}_amd64_bookworm.deb && \
dpkg -i zola_${ZOLAVERSION}_amd64_bookworm.deb && rm zola_${ZOLAVERSION}_amd64_bookworm.deb
#RUN apk add --no-cache zola --repository http://dl-cdn.alpinelinux.org/alpine/edge/community/
ARG GITPROJECTNAME=serinty-website
+1 -1
View File
@@ -1,4 +1,4 @@
version: '3.8'
#version: '3.8'
services:
sws4zola:
restart: unless-stopped
+59 -10
View File
@@ -44,7 +44,8 @@ BASE_PROTOCOL=${BASE_PROTOCOL:-"http"}
BASE_URL=${BASE_URL:-"${BASE_PROTOCOL}://${BASE_DOMAIN}:${SWSPORT}"}
# Zola output build and sws path
OUTPUT_DIR=${OUTPUT_DIR:-$HOME/$GITPROJECTUSER/$GITPROJECTNAME/public}
#OUTPUT_DIR=${OUTPUT_DIR:-$HOME/$GITPROJECTUSER/$GITPROJECTNAME/public}
OUTPUT_DIR=${OUTPUT_DIR:-$HOME/$GITPROJECTNAME/public}
GITBRANCHNAME=${GITBRANCHNAME:-"master"}
@@ -69,6 +70,40 @@ startSWSifNotRunning () {
fi
}
isNewContent() {
# Fehlercode 2 bei Fehlern, 1 wenn keine neuen Inhalte, 0 wenn neue Inhalte vorhanden
# Überprüfe, ob es sich um ein Git-Repository handelt
if [ ! -d .git ]; then
return 2
fi
# Ermittle aktuellen Branch
current_branch=$(git rev-parse --abbrev-ref HEAD 2>/dev/null)
if [ $? -ne 0 ]; then
return 2
fi
# Hole Remote-Änderungen
git fetch origin --quiet 2>/dev/null
if [ $? -ne 0 ]; then
return 2
fi
# Prüfe auf neue Commits
new_commits=$(git rev-list --count HEAD..origin/"$current_branch" 2>/dev/null)
if [ $? -ne 0 ]; then
return 2
fi
# Ergebnisinterpretation
if [ "$new_commits" -gt 0 ]; then
return 0 # Neue Inhalte vorhanden
else
return 1 # Keine neuen Inhalte
fi
}
# pull new data an build site
buildSite () {
goProjectPath
@@ -141,11 +176,9 @@ getTheme () {
echo "check if there are changes in the theme repository"
git fetch || errorAndExit "can't fetch theme repository" 4
# with --quiet diff though only error codes
if git diff --quiet FETCH_HEAD;
#if git diff --quiet FETCH_HEAD;
if isNewContent;
then
echo "no changes detected in theme"
goProjectPath
else
echo "getting updated design"
git pull origin "${GITBRANCHNAME}" --allow-unrelated-histories --ff-only || errorAndExit "can't pull theme repository" 4
if [ -f makefile ]
@@ -154,7 +187,13 @@ getTheme () {
make || errorAndExit "error interate external libraries" 6
fi
buildSite
elif [ $? -eq 1 ]; then
echo "no changes detected in theme"
goProjectPath
else
echo "error checking repository"
fi
else
errorAndExit "no theme ${THEME_NAME} found" 5
fi
@@ -164,14 +203,23 @@ getContent () {
goProjectPath
# check if there are changes in the content repository
echo "check if there are changes in the content repository"
git fetch || errorAndExit "can't fetch content repository" 4
if git diff --quiet FETCH_HEAD;
#git fetch || errorAndExit "can't fetch content repository" 4
#if git diff --quiet FETCH_HEAD;
if isNewContent;
then
echo "no changes detected in the cintent repository"
else
echo "getting updated content"
git pull origin "${GITBRANCHNAME}" --allow-unrelated-histories --ff-only || errorAndExit "can't pull content repository" 1
buildSite
elif [ $? -eq 1 ]; then
echo "no changes detected in the content repository"
if [ ! -d public ]
then
echo "no public found, start buiding site"
getTheme
buildSite
fi
else
errorAndExit "can't fetch content repository" 4
fi
}
@@ -198,7 +246,8 @@ if [ ! -d "${GITPROJECTNAME}" ]; then
getTheme
else
goProjectPath
startSWSifNotRunning
getContent
getTheme
fi
while true