You've already forked hugo-docker
mirror of
https://github.com/jakejarvis/hugo-docker.git
synced 2025-06-30 20:56:38 -04:00
Compare commits
75 Commits
Author | SHA1 | Date | |
---|---|---|---|
4a98dad700
|
|||
e91bc2ed98 | |||
048f5d17f2
|
|||
5c457e33fe
|
|||
0a8ca90615
|
|||
8b514c58d7
|
|||
20f98c58b7
|
|||
a10483b36a
|
|||
e5a6870534
|
|||
62b12c0d22
|
|||
df27582975
|
|||
6cc3f39751
|
|||
8540c876dd
|
|||
e806604521
|
|||
7fc2ac2b8e
|
|||
56a30dab8f
|
|||
f49e3b1dcd
|
|||
2de4b89509
|
|||
10103bce3b
|
|||
fcb292357c
|
|||
61fa24ed38
|
|||
250387c4f1
|
|||
6e5386c78a
|
|||
86af318435
|
|||
5bbac6174f
|
|||
9fc7783e5a
|
|||
4f26d81802
|
|||
de42257aa2
|
|||
e10c7362c7
|
|||
5bd125e947
|
|||
92aeed4a00
|
|||
23cd994860
|
|||
5bbdb9ba12
|
|||
b69006cb54
|
|||
f0b59209e5
|
|||
061289816b | |||
e59900daaa
|
|||
92748c6c0f | |||
18a14635c0
|
|||
3cb403f6fa
|
|||
70c9d418ec
|
|||
4ec3e8be98
|
|||
f1513cf6c7
|
|||
e608453299
|
|||
7a43febe15
|
|||
4898a96b66
|
|||
73e0bf7815
|
|||
d6ca9055b4
|
|||
bca0721d67
|
|||
33bd893ed3
|
|||
d9338044c5
|
|||
cb26219a40
|
|||
f6580ec25c
|
|||
6bc21e062a
|
|||
04930ae9ae
|
|||
eb82474eb8
|
|||
90b15c893d
|
|||
b31b18ac2d
|
|||
4df70ef38c
|
|||
f75b85512b
|
|||
f97154879d
|
|||
4f1d3a9c48
|
|||
22ba6e27d0
|
|||
3123853163
|
|||
5d7840092e
|
|||
7d20947610 | |||
a6b5427dca
|
|||
941079893a
|
|||
8a2fe24434
|
|||
bdf6d208b4
|
|||
de4ef2242f
|
|||
a7e4ccee25
|
|||
77fc7a219c
|
|||
b9d9a45c6a | |||
912a1f4176
|
18
.github/workflows/build.yml
vendored
18
.github/workflows/build.yml
vendored
@ -6,13 +6,15 @@ on:
|
||||
- master
|
||||
tags:
|
||||
- 'v*'
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
docker:
|
||||
runs-on: ubuntu-latest
|
||||
if: "!contains(github.event.head_commit.message, '[skip ci]')"
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Prepare tags
|
||||
id: tag
|
||||
@ -32,16 +34,16 @@ jobs:
|
||||
echo ::set-output name=tags::${TAGS}
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@master
|
||||
uses: docker/setup-qemu-action@v2
|
||||
with:
|
||||
platforms: all
|
||||
platforms: linux/amd64,linux/arm64
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
id: buildx
|
||||
uses: docker/setup-buildx-action@master
|
||||
uses: docker/setup-buildx-action@v2
|
||||
|
||||
- name: Cache Docker layers
|
||||
uses: actions/cache@v2
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: /tmp/.buildx-cache
|
||||
key: ${{ runner.os }}-buildx-${{ github.sha }}
|
||||
@ -50,14 +52,14 @@ jobs:
|
||||
|
||||
- name: Login to DockerHub
|
||||
if: github.event_name != 'pull_request'
|
||||
uses: docker/login-action@v1
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
username: jakejarvis
|
||||
password: ${{ secrets.DOCKER_HUB_TOKEN }}
|
||||
|
||||
- name: Login to GitHub Container Registry
|
||||
if: github.event_name != 'pull_request'
|
||||
uses: docker/login-action@v1
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.repository_owner }}
|
||||
@ -65,7 +67,7 @@ jobs:
|
||||
|
||||
- name: Build and push
|
||||
id: build
|
||||
uses: docker/build-push-action@v2
|
||||
uses: docker/build-push-action@v3
|
||||
with:
|
||||
builder: ${{ steps.buildx.outputs.name }}
|
||||
context: ./
|
||||
|
91
Dockerfile
91
Dockerfile
@ -1,12 +1,15 @@
|
||||
# the following version can be overridden at image build time with --build-arg
|
||||
ARG HUGO_VERSION=0.82.0
|
||||
ARG HUGO_VERSION=0.111.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.19
|
||||
ARG ALPINE_VERSION=3.17
|
||||
|
||||
# ---
|
||||
|
||||
# Hugo >= v0.81.0 requires Go 1.16+ to build
|
||||
FROM golang:1.16-alpine3.13 AS build
|
||||
FROM golang:${GO_VERSION}-alpine${ALPINE_VERSION} AS build
|
||||
|
||||
# renew global args from above
|
||||
# https://docs.docker.com/engine/reference/builder/#scope
|
||||
@ -21,13 +24,11 @@ ENV GO111MODULE=on
|
||||
WORKDIR /go/src/github.com/gohugoio/hugo
|
||||
|
||||
# gcc/g++ are required to build SASS libraries for extended version
|
||||
RUN apk update && \
|
||||
apk add --no-cache \
|
||||
RUN apk add --update --no-cache \
|
||||
gcc \
|
||||
g++ \
|
||||
musl-dev \
|
||||
git && \
|
||||
go get github.com/magefile/mage
|
||||
git
|
||||
|
||||
# clone source from Git repo:
|
||||
RUN git clone \
|
||||
@ -36,24 +37,25 @@ 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
|
||||
# https://github.com/gohugoio/hugo/commit/241481931f5f5f2803cd4be519936b26d8648dfd
|
||||
RUN go build -v -ldflags "-X github.com/gohugoio/hugo/common/hugo.vendorInfo=docker" -tags "$HUGO_BUILD_TAGS" && \
|
||||
mv ./hugo /go/bin/hugo
|
||||
|
||||
# fix potential stack size problems on Alpine
|
||||
# https://github.com/microsoft/vscode-dev-containers/blob/fb63f7e016877e13535d4116b458d8f28012e87f/containers/hugo/.devcontainer/Dockerfile#L19
|
||||
RUN go get github.com/yaegashi/muslstack && \
|
||||
RUN go install github.com/yaegashi/muslstack@latest && \
|
||||
muslstack -s 0x800000 /go/bin/hugo
|
||||
|
||||
# ---
|
||||
|
||||
FROM alpine:3.13
|
||||
FROM alpine:${ALPINE_VERSION}
|
||||
|
||||
# renew global args from above
|
||||
# renew global args from above & pin any dependency versions
|
||||
ARG HUGO_VERSION
|
||||
# https://github.com/jgm/pandoc/releases
|
||||
ARG PANDOC_VERSION=2.19.2
|
||||
# https://github.com/sass/dart-sass-embedded/releases
|
||||
ARG DART_SASS_VERSION=1.58.3
|
||||
|
||||
LABEL version="${HUGO_VERSION}"
|
||||
LABEL repository="https://github.com/jakejarvis/hugo-docker"
|
||||
@ -64,17 +66,26 @@ LABEL maintainer="Jake Jarvis <jake@jarv.is>"
|
||||
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
|
||||
COPY --from=build /go/bin/hugo /usr/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 && \
|
||||
apk add --no-cache \
|
||||
# this step is intentionally a bit of a mess to minimize the number of layers in the final image
|
||||
RUN set -euo pipefail && \
|
||||
if [ "$(uname -m)" = "x86_64" ]; then \
|
||||
ARCH="amd64"; \
|
||||
elif [ "$(uname -m)" = "aarch64" ]; then \
|
||||
ARCH="arm64"; \
|
||||
else \
|
||||
echo "Unknown build architecture, quitting." && exit 2; \
|
||||
fi && \
|
||||
# alpine packages
|
||||
# libc6-compat & libstdc++ are required for extended SASS libraries
|
||||
# ca-certificates are required to fetch outside resources (like Twitter oEmbeds)
|
||||
apk add --update --no-cache \
|
||||
ca-certificates \
|
||||
tzdata \
|
||||
git \
|
||||
nodejs \
|
||||
npm \
|
||||
yarn \
|
||||
go \
|
||||
python3 \
|
||||
py3-pip \
|
||||
@ -82,24 +93,50 @@ RUN apk update && \
|
||||
libc6-compat \
|
||||
libstdc++ && \
|
||||
update-ca-certificates && \
|
||||
# npm packages
|
||||
npm install --global --production \
|
||||
yarn \
|
||||
postcss \
|
||||
postcss-cli \
|
||||
autoprefixer \
|
||||
@babel/core \
|
||||
@babel/cli && \
|
||||
npm cache clean --force && \
|
||||
# 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 --no-cache-dir --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/bin/ && \
|
||||
chmod +x /usr/bin/pandoc && \
|
||||
rm -rf pandoc.tar.gz pandoc-${PANDOC_VERSION} && \
|
||||
# manually fetch Dart SASS binary (on x64 only)
|
||||
if [ "$ARCH" = "amd64" ]; then \
|
||||
wget -O sass-embedded.tar.gz https://github.com/sass/dart-sass-embedded/releases/download/${DART_SASS_VERSION}/sass_embedded-${DART_SASS_VERSION}-linux-x64.tar.gz && \
|
||||
tar xf sass-embedded.tar.gz && \
|
||||
mv ./sass_embedded/dart-sass-embedded /usr/bin/ && \
|
||||
chmod +x /usr/bin/dart-sass-embedded && \
|
||||
rm -rf sass-embedded.tar.gz sass_embedded; \
|
||||
fi && \
|
||||
# clean up some junk
|
||||
rm -rf /tmp/* /var/tmp/* /var/cache/apk/* && \
|
||||
# tell git to trust /src
|
||||
git config --global --add safe.directory /src && \
|
||||
# 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
|
||||
|
@ -1,8 +1,8 @@
|
||||
# ✏️ [Hugo Extended](https://github.com/gohugoio/hugo) via Docker
|
||||
# ✏️ [Hugo Extended](https://github.com/gohugoio/hugo) via Docker
|
||||
|
||||
[](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,11 @@ 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)
|
||||
- [Embedded Dart Sass](https://github.com/sass/dart-sass-embedded) (amd64 only)
|
||||
|
||||
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
|
||||
|
||||
|
Reference in New Issue
Block a user