-
-
Notifications
You must be signed in to change notification settings - Fork 7.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hugo binary does not run in Alpine: Error loading shared library libresolv.so.2 #10839
Comments
After further inspection and discussion, it seems this is due to #10691. |
Could hugo be built statically instead? In https://www.reddit.com/r/golang/comments/10te58n/comment/j7eq6yv/, someone posted this can be done with:
|
I don't think that will solve this particular issue, but I'm not sure. Technically yes. We do that for Windows (for practical reasons; it's not common to have But I would be very hesitant to do so for *nix, as that would mean that Hugo would determine which |
Understood. For the time being, I've changed my Dockerfile to build from source 🙂 |
For reference, here is a Dockerfile I used to work around this: # ------------------------------------------------------------------------------
# Base
FROM golang:1.20.2-alpine
SHELL ["/bin/ash", "-c"]
# ------------------------------------------------------------------------------
# Working directory
RUN set -exo pipefail && \
\
echo 'Create the working directory' && \
mkdir /work
WORKDIR /work
# ------------------------------------------------------------------------------
# Packages
RUN set -exo pipefail && \
\
echo 'Installing common packages' && \
apk add --update --no-cache \
build-base \
ca-certificates \
curl \
git \
libc6-compat \
libstdc++ \
make \
rsync
# ------------------------------------------------------------------------------
# Hugo
RUN set -exo pipefail && \
\
echo 'Seting up temporary environment variables' && \
VERSION=0.111.3 && \
SHA=b6eeb13d9ed2e5d5c6895bae56480bf0fec24a564ad9d17c90ede14a7b240999 && \
PACKAGE=hugo-"$VERSION".tar.gz && \
BASE=https://codeload.github.com/gohugoio/hugo/tar.gz/refs/tags && \
URL="$BASE/v$VERSION" && \
\
echo 'Downloading Hugo' && \
curl -fsSLo "$PACKAGE" "$URL" && \
\
echo 'Checking package signature' && \
sha256sum "$PACKAGE" && \
echo "$SHA $PACKAGE" | sha256sum -c - && \
\
echo 'Extracting package' && \
mkdir -p /var/hugo && \
tar -xzf "$PACKAGE" -C /var/hugo --strip-components=1 && \
rm -rf "$PACKAGE" && \
\
echo 'Compile Hugo' && \
cd /var/hugo && \
CGO_ENABLED=1 \
GOPATH=/var/hugo/gopath \
go build -v -o bin/hugo --tags extended -gcflags="-e" && \
mv bin/hugo /usr/local/bin/ && \
rm -rf /var/hugo ~/.cache ~/go
# ------------------------------------------------------------------------------
# Execution
CMD ["/usr/local/bin/hugo"] NOTE: this significantly increase the build time and size of the resulting image compared to downloading the precompiled package on top of an |
I assume it's the Go 1.20 changes mentioned here that breaks this: I'm guessing that Go bundled these C libraries into Go in <= 1.19. |
I was able to solve the problem with
|
Perfect, that fixed it for me, thank you |
I couldn't get this to work, even with @harrtho's helpful suggestion. I ended up installing the Alpine hugo package directly and replaced the binary: RUN apk update && \
apk add --no-cache hugo && \
rm ./node_modules/hugo-bin/vendor/hugo && \
ln -s /usr/bin/hugo ./node_modules/hugo-bin/vendor/hugo |
Also needed the libstdc++, so |
@bep This issue is still present in the 0.112.0 version of the build artefacts. Have you not added Up to you what approach you take, just note we would love to have a downloadable extended executable for alpine. |
I also meet this problem. After following your repair steps, it was not successful and another error message appeared:
|
I'm using my own gitlab.ci script like this, with Hugo version 0.119.
|
The current title of this issue, "Hugo extended cannot run in Alpine", is not accurate. See https://gohugo.io/installation/linux/#alpine-linux for installation instructions. The community package repo is updated regularly. |
I'm using the
amd64.tar.gz
binary from the releases page, and starting from0.111.0
, hugo extended fails to run in Alpine. This is not the case for0.110.0
. Seems something changed in the way the binaries are built in version0.111.0
. I found this commit that might be relevant 60e6fa7.The full error:
What version of Hugo are you using (
hugo version
)?I cannot answer this because
hugo
fails to run.Does this issue reproduce with the latest release?
Yes.
The text was updated successfully, but these errors were encountered: