365 Days of Code - Day 057

Project Status

ProjectLanguageStatusDue DateLatest Update
Personal WebsiteHugoOngoingNoneThe site is live. Continuous improvements ongoing.
Laravel From ScratchLaravel (PHP)In-Progress2026-03-31Episode 8
PRMLaravel (PHP)In-Progress2026-03-31Working alongside other Laravel projects.
Client Website (J.L.)Laravel (PHP)In-Progress2026-03-31Working alongside other Laravel projects.
Project EulerCOngoingNoneWorking on P25. BigInt (AI gen) was a waste of time, need to rewrite
Practice JavaJavaPausedNoneInstalled, need to find a good project.
Practice PythonPythonPausedNoneInstalled, need to find a good project.
Learn GoGoPausedNoneInstalled, work on LDAP Injector from ippsec.
Learn RustRustHaven’t StartedNoneInstalled, will try network protocols after finishing in C and Zig.
Learn ElixirElixirHaven’t StartedNoneInstalled, need a good tutorial project.
Learn HaskellHaskellHaven’t StartedNoneInstalled, need a good tutorial project.
Learn ZigZigHaven’t StartedNoneInstalled, will try network protocols after finishing in C.
Linux+N/AIn-Progress2026-03-31Reading Chapter 4.
Cyber Quest 2026N/AIn-Progress2026-02-28Finished quiz 1 with 75%.
Operating SystemsN/AIn-Progress2026-03-31Reading Chapter 4: Abstraction
Grey-Hat HackingVariousIn-Progress2026-03-31Reading Chapter 8: Threat Hunting Lab
PHP Time TrackerPHPBeta FinishedNoneWorking on a basic level.
HTTP Status Code ReaderCComplete2026-02-18Complete.
ZSH Configurationbash/zshCompleteNoneSort of an ongoing process, but complete for now. Works good.
Network ProtocolsCIn-ProgressNoneWorking on V3, implementing IPv6.
Discinox WebsiteHTML, CSS, JSComplete2026-03-04The site is live.
DiroffTech WebsiteHTML, CSS, JSComplete2026-03-05The site is live. git-lfs needs to be initialized for images.
Automate BackupsbashComplete2026-03-08Backups done.

Hugo Updates

I discarded all the updates from yesterday and started from scratch in a new branch today. I made some progress on the image processing when I noticed that Hugo had some nice updates for image processing in recent releases. It was time to update Hugo.

Updating Hugo locally is easy, but I did not have a mechanism for updating the Hugo version running in Docker in production.

First, update locally:

zsh
> wget https://github.com/gohugoio/hugo/releases/download/v0.158.0/hugo_0.158.0_linux-amd64.deb
> sudo dpkg -i ./hugo_0.158.0_linux-amd64.deb
> hugo version
hugo v0.158.0-f41be7959a44108641f1e081adf5c4be7fc1bb63 linux/amd64 BuildDate=2026-03-16T17:42:04Z VendorInfo=gohugoio
1
2
3
4
> wget https://github.com/gohugoio/hugo/releases/download/v0.158.0/hugo_0.158.0_linux-amd64.deb
> sudo dpkg -i ./hugo_0.158.0_linux-amd64.deb
> hugo version
hugo v0.158.0-f41be7959a44108641f1e081adf5c4be7fc1bb63 linux/amd64 BuildDate=2026-03-16T17:42:04Z VendorInfo=gohugoio

Let’s make sure the site works with the new version. I am anticipating some deprecated notices.

zsh
hugo server --disableFastRender --logLevel info | grep deprecated
1
hugo server --disableFastRender --logLevel info | grep deprecated

We get some notices that the language processing methods has been updated. This requires two updates, one to baseof.html and another to hugo.toml.

  • baseof.html
go
<html
  lang="{{ site.Language.Locale }}"
  dir="{{ or site.Language.Direction `ltr` }}"
>
1
2
3
4
<html
  lang="{{ site.Language.Locale }}"
  dir="{{ or site.Language.Direction `ltr` }}"
>
  • hugo.toml
toml
locale = 'en-US'
1
locale = 'en-US'

With these updated, I’m ready for the hard part, refactoring Dockerfile. This required nearly a full rewrite of the Dockerfile. I based it off of this post (opens in a new tab) on the Hugo forum. Luckily, user dvdksn had already done this for Docker before. I just needed to merge his code with my requirements.

Dockerfile
# syntax=docker/dockerfile:1

# ---------------------------------------------------
# Versioning
# ---------------------------------------------------
ARG ALPINE_VERSION=3.23
ARG HUGO_VERSION=0.158.0
ARG NODE_VERSION=24

# ---------------------------------------------------
# Stage 1: Get Hugo Binary
#
# Example download URL from Github Releases page - https://github.com/gohugoio/hugo/releases/
# https://github.com/gohugoio/hugo/releases/download/v0.158.0/hugo_0.158.0_linux-amd64.tar.gz
# ---------------------------------------------------
FROM alpine:${ALPINE_VERSION} AS hugo-downloader
WORKDIR /tmp/hugo
# Redeclare HUGO_VERSION so it can be used in RUN commands
ARG HUGO_VERSION
ARG TARGETARCH
RUN apk add --no-cache wget tar
RUN wget -O "hugo.tar.gz" "https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_${HUGO_VERSION}_linux-${TARGETARCH}.tar.gz"
RUN tar -xf "hugo.tar.gz" -C /usr/bin hugo

# ---------------------------------------------------
# Stage 2: Build the static site
# ---------------------------------------------------
FROM node:${NODE_VERSION}-alpine AS builder
RUN apk add --no-cache git
COPY --from=hugo-downloader /usr/bin/hugo /usr/bin/hugo
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci
COPY . .
RUN hugo --minify --gc

# ---------------------------------------------------
# Stage 3: Serve with Nginx
# ---------------------------------------------------
FROM nginx:alpine
COPY --from=builder /app/public /usr/share/nginx/html
COPY .nginx/default.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# syntax=docker/dockerfile:1

# ---------------------------------------------------
# Versioning
# ---------------------------------------------------
ARG ALPINE_VERSION=3.23
ARG HUGO_VERSION=0.158.0
ARG NODE_VERSION=24

# ---------------------------------------------------
# Stage 1: Get Hugo Binary
#
# Example download URL from Github Releases page - https://github.com/gohugoio/hugo/releases/
# https://github.com/gohugoio/hugo/releases/download/v0.158.0/hugo_0.158.0_linux-amd64.tar.gz
# ---------------------------------------------------
FROM alpine:${ALPINE_VERSION} AS hugo-downloader
WORKDIR /tmp/hugo
# Redeclare HUGO_VERSION so it can be used in RUN commands
ARG HUGO_VERSION
ARG TARGETARCH
RUN apk add --no-cache wget tar
RUN wget -O "hugo.tar.gz" "https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_${HUGO_VERSION}_linux-${TARGETARCH}.tar.gz"
RUN tar -xf "hugo.tar.gz" -C /usr/bin hugo

# ---------------------------------------------------
# Stage 2: Build the static site
# ---------------------------------------------------
FROM node:${NODE_VERSION}-alpine AS builder
RUN apk add --no-cache git
COPY --from=hugo-downloader /usr/bin/hugo /usr/bin/hugo
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci
COPY . .
RUN hugo --minify --gc

# ---------------------------------------------------
# Stage 3: Serve with Nginx
# ---------------------------------------------------
FROM nginx:alpine
COPY --from=builder /app/public /usr/share/nginx/html
COPY .nginx/default.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]

I tested locally first.

zsh
docker build -t local-hugo-test .
docker run -d --name hugo-test-container -p 8080:80 local-hugo-test
docker rm -f hugo-test-container
1
2
3
docker build -t local-hugo-test .
docker run -d --name hugo-test-container -p 8080:80 local-hugo-test
docker rm -f hugo-test-container

Everything worked great locally, but there was one more change to make. Due to the usage of the ARG TARGETARCH command, it was necessary to include Buildx in the workflow. And, since Buildx was being added, I might as well include caching. These statements were added to the workflow:

yml
- name: Set up Docker Buildx
  uses: docker/setup-buildx-action@v4

<snip>

  cache-from: type=gha
  cache-to: type=gha,mode=max
1
2
3
4
5
6
7
- name: Set up Docker Buildx
  uses: docker/setup-buildx-action@v4

<snip>

  cache-from: type=gha
  cache-to: type=gha,mode=max

With everything in place, I pushed the branch up to Github, submitted the PR, and merged the changes. The build fired off without a hitch. Very satisfying.

Now, I can finally get back to working on my image processing!

Related content