Skip to content

Instantly share code, notes, and snippets.

@schneidr
Last active November 7, 2022 10:18
Show Gist options
  • Save schneidr/908e57adf77db43eee2b1d799960b8d8 to your computer and use it in GitHub Desktop.
Save schneidr/908e57adf77db43eee2b1d799960b8d8 to your computer and use it in GitHub Desktop.
Compile environment for extended Hugo for CentOS 7

Usage

docker build -t hugo-build-centos .
docker run -it --rm -v $PWD:/work -e HUGO_VERSION=0.105.0 hugo-build-centos:latest

After the successful compilation only the hugo binary remains in the current directory.

#!/bin/env bash
PATH=$PATH:/usr/local/go/bin/
CGO_ENABLED=1
if [ -z "${HUGO_VERSION}" ];
then
echo "Hugo version missing"
echo "Example usage:"
echo "docker run -it --rm -v \$PWD:/work -e HUGO_VERSION=0.105.0 hugo-build-centos:latest"
exit 1
fi
wget https://github.com/gohugoio/hugo/archive/refs/tags/v${HUGO_VERSION}.zip
unzip v${HUGO_VERSION}.zip
cd hugo-${HUGO_VERSION}
go build --tags extended && cp hugo ..
cd ..
rm -rf hugo-${HUGO_VERSION} v${HUGO_VERSION}.zip
FROM centos:7
RUN yum install gcc gcc-c++ make unzip wget -y && \
wget https://go.dev/dl/go1.19.linux-amd64.tar.gz && \
tar -C /usr/local -xzf go*.linux-amd64.tar.gz && \
rm go*.linux-amd64.tar.gz
ADD compile_hugo.sh /usr/local/bin/compile_hugo.sh
WORKDIR /work
ENTRYPOINT /usr/local/bin/compile_hugo.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment