diff options
author | Bjørn Erik Pedersen <[email protected]> | 2024-10-09 11:39:36 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <[email protected]> | 2024-10-13 20:01:37 +0200 |
commit | 41f69a72553858395f402a16b9b74f21d10e5cfa (patch) | |
tree | bfe996b53c3cf12fc9e0a84400a37bedf6ff9b7b /scripts | |
parent | 4a79956276e735a4a21e09d134527b3a0247180d (diff) | |
download | hugo-41f69a72553858395f402a16b9b74f21d10e5cfa.tar.gz hugo-41f69a72553858395f402a16b9b74f21d10e5cfa.zip |
Upgrade to latest Go version + Some Docker image improvements (note)
* Rename /site to /project
* Add ldflags
* Add go and node to the default image
* Add Dart Sass to the default image
* Build the extended version by default
* Add "npm i" install support with custom entry script override
* Adjust cache logic to speed up CGO rebuilds
Closes #12920
See #12885
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/docker/entrypoint.sh | 21 | ||||
-rwxr-xr-x | scripts/docker/install_runtimedeps_default.sh | 20 |
2 files changed, 41 insertions, 0 deletions
diff --git a/scripts/docker/entrypoint.sh b/scripts/docker/entrypoint.sh new file mode 100755 index 000000000..20ffbe5f7 --- /dev/null +++ b/scripts/docker/entrypoint.sh @@ -0,0 +1,21 @@ +#!/bin/sh + +# Check if a custom hugo-docker-entrypoint.sh file exists. +if [ -f hugo-docker-entrypoint.sh ]; then + # Execute the custom entrypoint file. + sh hugo-docker-entrypoint.sh "$@" + exit $? +fi + +# Check if a package.json file exists. +if [ -f package.json ]; then + # Check if node_modules exists. + if [ ! -d node_modules ]; then + # Install npm packages. + # Note that we deliberately do not use `npm ci` here, as it would fail if the package-lock.json file is not up-to-date, + # which would be the case if you run the container with a different OS or architecture than the one used to create the package-lock.json file. + npm i + fi +fi + +exec "hugo" "$@"
\ No newline at end of file diff --git a/scripts/docker/install_runtimedeps_default.sh b/scripts/docker/install_runtimedeps_default.sh new file mode 100755 index 000000000..0b6c2c617 --- /dev/null +++ b/scripts/docker/install_runtimedeps_default.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +set -ex + +export DART_SASS_VERSION=1.79.3 + +# If $BUILDARCH=arm64, then we need to install the arm64 version of Dart Sass, +# otherwise we install the x64 version. +ARCH="x64" +if [ "$BUILDARCH" = "arm64" ]; then + ARCH="arm64" +fi + +cd /tmp +curl -LJO https://github.com/sass/dart-sass/releases/download/${DART_SASS_VERSION}/dart-sass-${DART_SASS_VERSION}-linux-${ARCH}.tar.gz +ls -ltr +tar -xf dart-sass-${DART_SASS_VERSION}-linux-${ARCH}.tar.gz +rm dart-sass-${DART_SASS_VERSION}-linux-${ARCH}.tar.gz && \ +# The dart-sass folder is added to the PATH by the caller. +mv dart-sass /var/hugo/bin
\ No newline at end of file |