mirror of
https://github.com/hugomods/docker.git
synced 2025-04-25 20:51:18 +03:00
🐳 The automated, up-to-date and minimal third party Hugo Docker Images. 自动化、最新和最小化的第三方 Hugo Docker 映像。
.github/workflows | ||
docker | ||
site | ||
LICENSE | ||
README.md | ||
renovate.json |
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
<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/.