docker build -t hugo-build-centos .
docker run -it --rm -v $PWD:/work -e HUGO_VERSION=0.105.0 hugo-build-centos:latestAfter 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 |