# 2025-08-13 Hyperling
# Changelog
## 20261027: Install hugo from source. paperMod currently requires ~150 and Debian has ~130, latest is ~160.

## Image ##
FROM debian:trixie-slim
USER root

## Setup ##
ARG DEBIAN_FRONTEND=noninteractive

# System Dependencies
RUN apt-get update && \
    apt-get install -y \
        git nginx cron curl bash sudo \
        golang gcc ca-certificates && \
    rm -rf /var/lib/apt/lists/*

# Compile Hugo (same version Artix is currently shipping, rather than latest.)
RUN CGO_ENABLED=1 go install -tags extended github.com/gohugoio/hugo@v0.164.0

# Install Hugo
RUN ln -s $HOME/go/bin/hugo /usr/local/bin/hugo

# User and Group
#RUN groupadd -r hugo && useradd -r -g hugo hugo

# Hugo Directory Tree
RUN mkdir -pv /var/www/hugo/

# NGINX Directory Tree
RUN mkdir -pv /var/www/html/

# Copy Cron Job to Update Git Repo
COPY files/crontab /etc/crontab
COPY files/cronjob.sh /var/www/hugo/cronjob.sh

# Hugo User Permissions
RUN chown -Rv www-data:www-data /var/www/
RUN chmod +x /var/www/hugo/cronjob.sh

# Copy Start Script
COPY files/main.sh /root/main.sh
RUN chmod +x /root/main.sh

## Main ##
# Install + Run Website
WORKDIR /var/www/
CMD /root/main.sh "$REPO" "$BRANCH" "$PROD" "$DEV"
