From 3524b2209e6de78ed9f1ad5a010ab483f4c5c7e2 Mon Sep 17 00:00:00 2001 From: erik Date: Fri, 3 May 2024 11:21:12 +0200 Subject: [PATCH] Install hugo from deb --- infrastructure/build/image/Dockerfile | 1 + .../build/image/resources/functions.sh | 22 +++++++++++++++++++ .../build/image/resources/install.sh | 4 +++- 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/infrastructure/build/image/Dockerfile b/infrastructure/build/image/Dockerfile index 4d3289b..34fc9e3 100644 --- a/infrastructure/build/image/Dockerfile +++ b/infrastructure/build/image/Dockerfile @@ -3,6 +3,7 @@ FROM clojure:lein # Prepare Entrypoint Script ADD resources /tmp +ENV HUGO_VERSION="0.125.5" ENV BUILDDIR="/etc/website" ENV SOURCEDIR="/etc/websitesource" ENV WEBSITEROOT="/var/www/html/website/" diff --git a/infrastructure/build/image/resources/functions.sh b/infrastructure/build/image/resources/functions.sh index 88c5ec4..e857062 100644 --- a/infrastructure/build/image/resources/functions.sh +++ b/infrastructure/build/image/resources/functions.sh @@ -27,3 +27,25 @@ function build-website() { function move-website-files-to-target() { (cd $BUILDDIR; dir=$(ls); cd $dir; rsync -ru --exclude-from "/etc/exclude.pattern" --delete target/html/* $WEBSITEROOT;) } + +function install-hugo-from-deb() { + curl -L "https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb" -o hugo_extended_${HUGO_VERSION}_linux-amd64.deb + curl -L "https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_${HUGO_VERSION}_checksums.txt" -o checksums.txt + EXPECTED_CHECKSUM="$(sha256sum hugo_extended_${HUGO_VERSION}_linux-amd64.deb)" + ACTUAL_CHECKSUM="$(grep hugo_extended_${HUGO_VERSION}_linux-amd64.deb checksums.txt)" + if [ "$EXPECTED_CHECKSUM" != "$ACTUAL_CHECKSUM" ] + then + >&2 echo 'ERROR: Invalid installer checksum' + rm hugo.deb + exit 1 + fi + + echo "Installing hugo" + echo + dpkg -i hugo_extended_${HUGO_VERSION}_linux-amd64.deb + + echo "Clean up" + rm hugo_extended_${HUGO_VERSION}_linux-amd64.deb + rm checksums.txt + +} diff --git a/infrastructure/build/image/resources/install.sh b/infrastructure/build/image/resources/install.sh index 7616996..ae19d85 100755 --- a/infrastructure/build/image/resources/install.sh +++ b/infrastructure/build/image/resources/install.sh @@ -6,7 +6,8 @@ function main() { { upgradeSystem - apt-get install -qqy unzip rsync jq imagemagick curl hugo + apt-get install -qqy unzip rsync jq imagemagick curl + install-hugo-from-deb install -d /etc/lein/ install -m 0700 /tmp/entrypoint.sh / @@ -22,4 +23,5 @@ function main() } source /tmp/install_functions_debian.sh +source /tmp/functions.sh DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes main \ No newline at end of file