hugo, allow specifying the baseURL since it's helpful for SEO and other things, also rename PORT variables to not collide with Ansible's PROD_PORT.

This commit is contained in:
me committed 2026-11-02 15:08:59 -07:00
1 parent a5c1eef4a8
commit 2f2484df93
5 files changed
+23 -12

No files matched your search

+1 -1
View File
@@ -47,4 +47,4 @@ RUN chmod +x /root/main.sh
## Main ##
# Install + Run Website
WORKDIR /var/www/
CMD /root/main.sh "$REPO" "$BRANCH" "$PROD" "$DEV"
CMD /root/main.sh "$REPO" "$BRANCH" "$PROD" "$DEV" "$BASEURL"
@@ -9,13 +9,14 @@ services:
image: hyperling/hugo:$BRANCH
restart: always
ports:
- $PROD_PORT:80 # Production minified files served using NGINX.
#- $DEV_PORT:1380 # Development files with drafts served by Hugo Server.
- $NGINX_PORT:80 # Production minified files served using NGINX.
#- $HUGO_PORT:1380 # Development files with drafts served by Hugo Server.
environment:
- REPO=$REPO
- BRANCH=$BRANCH
- PROD=$PROD
- DEV=$DEV
- PROD=$NGINX
- DEV=$HUGO
- BASEURL=$BASEURL
healthcheck:
test: curl -sS http://localhost:80 || curl -sS http://localhost:1380 || exit 1
interval: 1m
+6 -4
View File
@@ -16,12 +16,14 @@ BRANCH=prod
# Please use values YES/TRUE and NO/FALSE.
# Whether to start NGINX
PROD=YES
PROD_PORT=8013
NGINX=YES
NGINX_PORT=8013
# Whether to start Hugo Server
DEV=NO
DEV_PORT=1380
HUGO=NO
HUGO_PORT=1380
BASEURL=https://blog.hyperling.com
#
## Resources ##
+2 -1
View File
@@ -3,6 +3,7 @@
cd /var/www/hugo/site
FORCE="$1"
BASEURL="$2"
echo "*** Running cronjob @ `date` ***"
@@ -16,7 +17,7 @@ if [[ $status != 0 && -e /var/www/html/index.html && -z $FORCE ]]; then
fi
# If the project was not already up to date, build the new files for NGINX.
/usr/local/bin/hugo --gc --minify
/usr/local/bin/hugo $BASEURL --gc --minify
status="$?"
echo "* Hugo status is '$status', FORCE is '$FORCE'."
if [[ $status == 0 && -e public/index.html ]]; then
+9 -2
View File
@@ -17,6 +17,13 @@ DEV="$4"
typeset -u DEV
echo "DEV='$DEV'"
BASEURL="$5"
echo "BASEURL='$BASEURL'"
baseurl=""
if [[ -n "$BASEURL" ]]; then
baseurl="-b $BASEURL"
fi
SITE="/var/www/hugo/site"
CLONE="/var/www/hugo/site-new"
@@ -40,7 +47,7 @@ mv -v $CLONE $SITE
echo "*** Copying Static Files to NGINX ***"
rm -rfv /var/www/html/*
sudo -u www-data /var/www/hugo/cronjob.sh
sudo -u www-data /var/www/hugo/cronjob.sh "" "$baseurl"
echo "*** Starting Cron ***"
service cron start
@@ -73,7 +80,7 @@ if [[ "$DEV" == "Y"* || "$DEV" == "T"* ]]; then
echo "* Dev server not detected, starting..."
cd $SITE
killall hugo 2>/dev/null
sudo -u www-data hugo server -D -F --noBuildLock --bind 0.0.0.0 -p 1380 &
sudo -u www-data hugo server $baseurl -D -F --noBuildLock --bind 0.0.0.0 -p 1380 &
fi
sleep 30
done &