1
mirror of https://github.com/jakejarvis/hugo-docker.git synced 2025-04-26 14:08:28 -04:00

add pandoc & docutils to final image

This commit is contained in:
Jake Jarvis 2021-03-30 17:51:44 -04:00
parent b807ac60eb
commit 912a1f4176
Signed by: jake
GPG Key ID: 2B0C9CF251E69A39
2 changed files with 40 additions and 20 deletions

View File

@ -3,10 +3,12 @@ ARG HUGO_VERSION=0.82.0
# remove/comment the following line completely to compile vanilla Hugo:
ARG HUGO_BUILD_TAGS=extended
# Hugo >= v0.81.0 requires Go 1.16+ to build
ARG GO_VERSION=1.16
# ---
# Hugo >= v0.81.0 requires Go 1.16+ to build
FROM golang:1.16-alpine3.13 AS build
FROM golang:${GO_VERSION}-alpine AS build
# renew global args from above
# https://docs.docker.com/engine/reference/builder/#scope
@ -36,11 +38,6 @@ RUN git clone \
--depth 1 \
https://github.com/gohugoio/hugo.git ./
# download source from GitHub release (old method):
# RUN wget https://github.com/gohugoio/hugo/archive/v${HUGO_VERSION}.tar.gz && \
# tar xf v${HUGO_VERSION}.tar.gz --strip-components=1 && \
# rm v${HUGO_VERSION}.tar.gz
RUN mage -v hugo && mage install
# fix potential stack size problems on Alpine
@ -50,10 +47,11 @@ RUN go get github.com/yaegashi/muslstack && \
# ---
FROM alpine:3.13
FROM alpine:latest
# renew global args from above
# renew global args from above & pin any dependency versions
ARG HUGO_VERSION
ARG PANDOC_VERSION=2.13
LABEL version="${HUGO_VERSION}"
LABEL repository="https://github.com/jakejarvis/hugo-docker"
@ -66,15 +64,22 @@ LABEL org.opencontainers.image.source="https://github.com/jakejarvis/hugo-docker
# bring over patched binary from build stage
COPY --from=build /go/bin/hugo /usr/local/bin/hugo
# libc6-compat & libstdc++ are required for extended SASS libraries
# ca-certificates are required to fetch outside resources (like Twitter oEmbeds)
RUN apk update && \
# this step is intentionally a bit of a mess to minimize the number of layers in the final image
RUN if [ "$(uname -m)" = "aarch64" ]; then \
export ARCH="arm64"; \
else \
export ARCH="amd64"; \
fi && \
# alpine packages
# libc6-compat & libstdc++ are required for extended SASS libraries
# ca-certificates are required to fetch outside resources (like Twitter oEmbeds)
apk update && \
apk add --no-cache \
ca-certificates \
tzdata \
git \
nodejs \
npm \
yarn \
go \
python3 \
py3-pip \
@ -82,24 +87,37 @@ RUN apk update && \
libc6-compat \
libstdc++ && \
update-ca-certificates && \
# npm packages
npm install --global --production \
yarn \
postcss \
postcss-cli \
autoprefixer \
@babel/core \
@babel/cli && \
# ruby gems
gem install asciidoctor && \
pip3 install --upgrade Pygments==2.*
# verify everything's OK, exit otherwise
RUN hugo env && \
# python packages
python3 -m pip install --upgrade Pygments==2.* docutils && \
# manually fetch pandoc binary
wget -O pandoc.tar.gz https://github.com/jgm/pandoc/releases/download/${PANDOC_VERSION}/pandoc-${PANDOC_VERSION}-linux-${ARCH}.tar.gz && \
tar xf pandoc.tar.gz && \
mv ./pandoc-${PANDOC_VERSION}/bin/pandoc /usr/local/bin/ && \
chmod +x /usr/local/bin/pandoc && \
rm -rf pandoc.tar.gz pandoc-${PANDOC_VERSION} && \
# make super duper sure that everything went OK, exit otherwise
hugo env && \
go version && \
node --version && \
npm --version && \
yarn --version && \
postcss --version && \
autoprefixer --version && \
babel --version && \
pygmentize -V && \
asciidoctor --version
asciidoctor --version && \
pandoc --version && \
rst2html.py --version
# add site source as volume
VOLUME /src

View File

@ -2,7 +2,7 @@
[![Build](https://github.com/jakejarvis/hugo-docker/actions/workflows/build.yml/badge.svg?branch=master)](https://github.com/jakejarvis/hugo-docker/actions/workflows/build.yml)
A base image to ease local development of Hugo sites, including [Hugo Extended](https://gohugo.io/troubleshooting/faq/#i-get-tocss-this-feature-is-not-available-in-your-current-hugo-version) (with SASS/SCSS support) and optional third-party tools ([listed below](#third-party-software)). Now includes native support for both AMD64 and ARM64 platforms!
A base image to ease local development of Hugo sites, including [Hugo Extended](https://gohugo.io/troubleshooting/faq/#i-get-tocss-this-feature-is-not-available-in-your-current-hugo-version) (with SASS/SCSS support) and optional third-party tools ([listed below](#third-party-software)). Now with [multi-architecture images](https://docs.docker.com/docker-for-mac/multi-arch/) for native AMD64 and ARM64 support!
## Usage
@ -42,8 +42,10 @@ Just in case, the final Alpine Linux container includes a few small third-party
- [Babel](https://babeljs.io/)
- [Pygments](https://pygments.org/)
- [Asciidoctor](https://asciidoctor.org/)
- [Pandoc](https://pandoc.org/)
- [Docutils](https://docutils.sourceforge.io/) / [RST](https://docutils.sourceforge.io/rst.html)
Node (with NPM and Yarn) and Go (for [Hugo Modules](https://gohugo.io/hugo-modules/) support) are also pre-installed.
Node (with NPM and Yarn), Go (for [Hugo Modules](https://gohugo.io/hugo-modules/) support), and Python are also pre-installed.
## Licenses