- November 11, 2017
- 2 min read
Dockerizing Hugo Sites
Hugo is a great OSS project that can be used to create static sites that are based on markdown files stored in a git repository. My personal blog is created using hugo and hosted on AWS S3. I recently did some work to dockerize it and thought I'd write about it.
First thing I needed to do was create a docker image with hugo installed so I can build my hugo site. For more info on the docker image see the Dockerfile contents below, you can also check out the git repository here. As you can see from the below snippet, nothing major is going on here, I'm using golang alpine image as a base and then installing hugo and adding hugo to the system path.
FROM golang:1.8.3-alpine
ENV HUGO_VERSION 0.25
ENV HUGO_BINARY hugo_${HUGO_VERSION}_linux-64bit
ENV PATH=/usr/local/hugo:${PATH}
RUN set -x \
&& apk upgrade --update \
&& apk add --update ca-certificates bash curl wget \
&& rm -rf /var/cache/apk/* \
&& mkdir /usr/local/hugo \
&& wget https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/${HUGO_BINARY}.tar.gz -O /usr/local/hugo/${HUGO_BINARY}.tar.gz \
&& tar xzf /usr/local/hugo/${HUGO_BINARY}.tar.gz -C /usr/local/hugo/ \
&& rm /usr/local/hugo/${HUGO_BINARY}.tar.gz \
&& rm -rf /tmp/* /var/cache/apk/* In my Dockerfile for my personal hugo based blog I use multi stage builds feature in docker to generate static HTML using hugo. As you can see from below snipped that I'm using the "hugo-docker" image I created as builder image and create a directory named "blog" under /var/www/ and copy all files into that directory.
FROM rprakashg/hugo-docker as builder
RUN mkdir -p /var/www/blog
COPY . /var/www/blogNext, we switch the working directory to "/var/www/blog" and run hugo command as shown in below snippet to generate the static HTML
WORKDIR /var/www/blog
RUN hugoFinal image is built using the official nginx image from docker hub and we copy all generated HTML content from "public" folder into "/usr/share/nginx/html"
FROM nginx
COPY --from=builder /var/www/blog/public/ /usr/share/nginx/htmlYou can see the full docker file here
Lastly, I threw together couple of helpful bash scripts that I can use to build and run the container so I don't have to always remember the docker commands :)
The cool thing about this is I can now run my blog anywhere, I use to host my blog previously in azure with Wordpress and MySQL, by using hugo I freed myself from dependency to web servers, runtimes, databases etc. but was still dependant on AWS S3 to host the generated static HTML content. Even though its pretty minor you are sort of locked into AWS. Docker gives me freedom to run it anywhere and I love it :)
Hope that helps...
Cheers,
Ram
Related Posts
RAM GOPINATHAN
September 17, 2026
Onboarding Edge Devices to FlightCTL with FIDO Device Onboarding
How I wired FDO's owner service, a bootc image layering go-fdo-client on the FlightCTL agent base, and two Ansible playbooks together so edge devices enroll into FlightCTL with zero manual steps.
RAM GOPINATHAN
September 14, 2026
Provisioning Devices and Onboarding to FlightCTL
Building a bootc image with the FlightCTL agent, baking it into an AMI, and provisioning EC2 test devices that inject their enrollment credentials via cloud-init and show up as pending enrollments in FlightCTL.
RAM GOPINATHAN
September 12, 2026
Deploying FlightCTL on EKS: Edge Fleet Management with Keycloak OIDC
A step-by-step walkthrough of standing up FlightCTL on Amazon EKS with Keycloak OIDC auth, ALB ingress, and a dedicated NLB for mTLS device enrollment.