I used to use the klakegg/hugo
image, but it’s been a while since it was updated, so I created an up-to-date Hugo docker image for meeting my site’s requirements (>=0.110.0
), hope this image helps.
I set up a schedule (run every 30 min) workflow for checking and building the latest Hugo docker image as well, the images will be always keeping update.
- Repo: GitHub - hugomods/docker: 🐳 The automated, up-to-date and minimal Hugo Docker Images.
- Docker Hub: Docker
Hugo Docker Images
The up to date Hugo docker images.
There are two ways to check and build latest Hugo images.
- Waiting for the cron job (runs every 30 min).
- Trigger the job immediately by commenting on the issue.
Images
Image | Size | Extended | Go | Node | NPM | Git |
---|---|---|---|---|---|---|
latest , <version> |
![]() |
![]() |
![]() |
![]() |
![]() |
|
base , base-<version> |
![]() |
![]() |
![]() |
![]() |
![]() |
|
go , go-<version> |
![]() |
![]() |
![]() |
![]() |
![]() |
|
node , node-<version> |
![]() |
![]() |
![]() |
![]() |
![]() |
|
exts , exts-<version> |
![]() |
![]() |
![]() |
![]() |
![]() |
|
reg , reg-<version> |
![]() |
![]() |
![]() |
![]() |
![]() |
|
reg-base , reg-base-<version> |
![]() |
![]() |
![]() |
![]() |
![]() |
|
reg-go , reg-go-<version> |
![]() |
![]() |
![]() |
![]() |
![]() |
|
reg-node , reg-node-<version> |
![]() |
![]() |
![]() |
![]() |
![]() |
|
reg-exts , reg-exts-<version> |
![]() |
![]() |
![]() |
![]() |
![]() |
<version>
: the placeholder for Hugo version, i.e.0.111.3
.reg
: represents the regular Hugo version.exts
: theexts
includes not only the tools listed above, but also Dart Sass Embedded, PostCSS CLI, Autoprefixer, PurgeCSS and RTLCSS.
Usage
Let’s take razonyang/hugo
image as an example.
$ docker pull razonyang/hugo
Start Hugo Server
$ docker run -p 1313:1313 \
-v ${PWD}:/src \
razonyang/hugo \
hugo server --bind 0.0.0.0
Note that
--bind 0.0.0.0
is required.
Using another port than 1313
, such as 8080
.
$ docker run -p 8080:8080 \
-v ${PWD}:/src \
razonyang/hugo \
hugo server --bind 0.0.0.0 -p 8080
Build Site
The example uses Nginx as web server to serve Hugo generated static files.
Firstly, create the Dockerfile
file on your site root.
###############
# Build Stage #
###############
FROM razonyang/hugo:exts as builder
# Base URL
ARG HUGO_BASEURL=
ENV HUGO_BASEURL=${HUGO_BASEURL}
# Build site
COPY . /src
RUN hugo --minify --gc --enableGitInfo
# Set the fallback 404 page if defaultContentLanguageInSubdir is enabled, please replace the `en` with your default language code.
# RUN cp ./public/en/404.html ./public/404.html
###############
# Final Stage #
###############
FROM razonyang/hugo:nginx
COPY --from=builder /src/public /site
docker build -t user/my-site .
You may want to check the built image.
docker build -t user/my-site --build-arg HUGO_BASEURL=http://localhost:8080 .
docker run -p 8080:80 user/my-site
Now the built site can be previewed on http://localhost:8080/.