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