Refactor how the project is run, using nginx instead of hugo server, a cron job to pull git changes, and a start script to ensure the correct services are started each run and are monitored to stay up.

This commit is contained in:
2025-08-15 11:45:23 -07:00
parent dfb9a306c5
commit d035f9d8e7
6 changed files with 112 additions and 17 deletions

View File

@@ -4,25 +4,32 @@
FROM debian:bookworm-slim
## Setup ##
# Cache System Dependencies
RUN apt-get update && apt-get install -y git hugo sudo curl wget bash
# System Dependencies
RUN apt-get update && apt-get install -y git hugo nginx cron curl bash sudo htop
RUN service nginx start
RUN service cron start
# User and Group
RUN groupadd -r hugo && useradd -r -s /usr/bin/bash -g hugo hugo
RUN groupadd -r hugo && useradd -r -g hugo hugo
# Directory Tree
# Hugo Directory Tree
RUN mkdir -pv /var/www/hugo && chown -Rv hugo:hugo /var/www/hugo
# NGINX Directory Tree
RUN mkdir -pv /var/www/html/ && chown -Rv hugo:hugo /var/www/html/
# Copy Cron Job to Update Git Repo
COPY files/hugo.crontab /etc/cron.d/hugo
COPY files/hugo.cronjob.sh /var/www/hugo/cronjob.sh
RUN chmod +x /var/www/hugo/cronjob.sh
RUN crontab /etc/cron.d/hugo
# Copy Start Script
COPY files/main.sh /root/main.sh
RUN chmod +x /root/main.sh
## Main ##
# Install + Run Website
WORKDIR /var/www/hugo
USER hugo
CMD echo "*** Cloning Repo $REPO ***" && \
cd /var/www/hugo && \
rm -rfv site && \
git clone --recurse-submodules $REPO site && \
cd site && \
mkdir -pv public && \
echo "*** Starting Hugo ***" && \
hugo version && \
hugo server -D --noBuildLock --bind 0.0.0.0
WORKDIR /var/www/
USER root
CMD /root/main.sh "$REPO" "$PROD" "$DEV"