Repository: gohugoio/hugo (language: go)

Issue:
Dockerfile Dart Sass permission issue on MacOS
```
Watching for changes in /project/{archetypes,assets,content,layouts,package.json,postcss.config.js,static}
Watching for config changes in /project/hugo.toml, /project/config/_default, /project/go.mod
Start building sites … 
hugo v0.136.0+extended linux/arm64 BuildDate=unknown VendorInfo=docker

ERROR TOCSS-DART: failed to transform "/sass/main.scss" (text/x-scss): got unexpected EOF when executing "sass". The user running hugo must have read and execute permissions on this program. With execute permissions only, this error is thrown.
ERROR render: failed to render pages: render of "page" failed: "/project/layouts/_default/dart-sass.html:25:23": execute of template failed: template: _default/dart-sass.html:25:23: executing "main" at <.Content>: error calling Content: TOCSS-DART: failed to transform "/temp/sass" (application/octet-stream): "<stream>:1:1": connection is shut down
Built in 593 ms
Error: error building site: TOCSS-DART: failed to transform "/temp/sass" (application/octet-stream): "<stream>:1:1": connection is shut down
````


Discussion / hints:

Fix patch:
diff --git a/Dockerfile b/Dockerfile
index 394133aed9e..01e82dbf49a 100755
--- a/Dockerfile
+++ b/Dockerfile
@@ -3,7 +3,8 @@
 # Website:      https://gohugo.io/
 
 ARG GO_VERSION="1.23.2"
-ARG ALPINE_VERSION=3.20
+ARG ALPINE_VERSION="3.20"
+ARG DART_SASS_VERSION="1.79.3"
 
 FROM --platform=$BUILDPLATFORM tonistiigi/xx:1.5.0 AS xx
 FROM --platform=$BUILDPLATFORM golang:${GO_VERSION}-alpine${ALPINE_VERSION} AS gobuild
@@ -45,6 +46,15 @@ RUN --mount=target=. \
     xx-verify /usr/bin/hugo
 EOT
 
+# dart-sass downloads the dart-sass runtime dependency
+FROM alpine:${ALPINE_VERSION} AS dart-sass
+ARG TARGETARCH
+ARG DART_SASS_VERSION
+ARG DART_ARCH=${TARGETARCH/amd64/x64}
+WORKDIR /out
+ADD https://github.com/sass/dart-sass/releases/download/${DART_SASS_VERSION}/dart-sass-${DART_SASS_VERSION}-linux-${DART_ARCH}.tar.gz .
+RUN tar -xf dart-sass-${DART_SASS_VERSION}-linux-${DART_ARCH}.tar.gz
+
 FROM gorun AS final
 
 COPY --from=build /usr/bin/hugo /usr/bin/hugo
@@ -54,14 +64,13 @@ RUN apk add --no-cache \
     libc6-compat \
     git \
     runuser \
-    curl \
     nodejs \
     npm
 
-RUN mkdir -p /var/hugo/bin && \
+RUN mkdir -p /var/hugo/bin /cache && \
     addgroup -Sg 1000 hugo && \
     adduser -Sg hugo -u 1000 -h /var/hugo hugo && \
-    chown -R hugo: /var/hugo && \
+    chown -R hugo: /var/hugo /cache && \
     # For the Hugo's Git integration to work.
     runuser -u hugo -- git config --global --add safe.directory /project && \ 
     # See https://github.com/gohugoio/hugo/issues/9810
@@ -71,15 +80,11 @@ VOLUME /project
 WORKDIR /project
 USER hugo:hugo
 ENV HUGO_CACHEDIR=/cache
-ARG BUILDARCH
-ENV BUILDARCH=${BUILDARCH}
 ENV PATH="/var/hugo/bin:$PATH"
 
-COPY scripts/docker scripts/docker
 COPY scripts/docker/entrypoint.sh /entrypoint.sh
+COPY --link --from=dart-sass /out/dart-sass /var/hugo/bin/dart-sass
 
-# Install default dependencies.
-RUN scripts/docker/install_runtimedeps_default.sh
 # Update PATH to reflect the new dependencies.
 # For more complex setups, we should probably find a way to
 # delegate this to the script itself, but this will have to do for now.
@@ -92,4 +97,3 @@ EXPOSE 1313
 
 ENTRYPOINT ["/entrypoint.sh"]
 CMD ["--help"]
-
diff --git a/scripts/docker/install_runtimedeps_default.sh b/scripts/docker/install_runtimedeps_default.sh
deleted file mode 100755
index 0b6c2c61708..00000000000
--- a/scripts/docker/install_runtimedeps_default.sh
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/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


Test patch: