Skip to content
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 docker cannot find Go binary in PATH #12915

Closed
Int-Circuit opened this issue Oct 8, 2024 · 3 comments
Closed

Hugo docker cannot find Go binary in PATH #12915

Int-Circuit opened this issue Oct 8, 2024 · 3 comments

Comments

@Int-Circuit
Copy link

What version of Hugo are you using (hugo version)?

$ hugo version
0.135 (docker)

Does this issue reproduce with the latest release?

Yes

When using hugo to load the modules from my go.mod file, my CI on GitLab complains that the image hasn't "go" in it's PATH.
See log

log.txt

@Int-Circuit Int-Circuit changed the title Hugo docker cannot find Go bianry in PATH Hugo docker cannot find Go binary in PATH Oct 9, 2024
@bhavin192
Copy link
Contributor

bhavin192 commented Oct 13, 2024

I can see same behavior when building my site which uses Hugo modules. https://gitlab.com/emacs-apac/emacs-apac.gitlab.io/

$ podman run -v $(pwd):/site:z --rm -it --entrypoint "hugo" ghcr.io/gohugoio/hugo:v0.135.0
Total in 2 ms
Error: failed to load modules: failed to download modules: binary with name "go" not found in PATH

I was going through the Dockerfile and saw that we don't install Go in the final stage so this error is expected.

hugo/Dockerfile

Lines 29 to 45 in 0398458

FROM alpine:3.18
COPY --from=build /go/bin/hugo /usr/bin/hugo
# libc6-compat & libstdc++ are required for extended SASS libraries
# ca-certificates are required to fetch outside resources (like Twitter oEmbeds)
RUN apk update && \
apk add --no-cache ca-certificates libc6-compat libstdc++ git
VOLUME /site
WORKDIR /site
# Expose port for live server
EXPOSE 1313
ENTRYPOINT ["hugo"]
CMD ["--help"]

I'm assuming Hugo modules are commonly used now a days, so should we include Go installation in the final stage?

Installing Go in alpine image

I tried this with following Dockerfile:

FROM ghcr.io/gohugoio/hugo:v0.135.0
RUN apk add --no-cache go

Impact is the image size, it is increased by ~300MB

$ podman images
REPOSITORY                                 TAG               IMAGE ID      CREATED         SIZE
docker.io/bhavin192/hugo                   v0.135.0-go       63f69e93cf2a  48 seconds ago  453 MB
ghcr.io/gohugoio/hugo                      v0.135.0          dc91d5ca1b66  2 weeks ago     138 MB

Use same image as the build stage?

Other option is to use the same base image we use for the build stage which seems to be smaller than installing Go via apk. But I haven't tried doing that, so don't know what will be size of the final image.

@bep
Copy link
Member

bep commented Oct 13, 2024

Fixed in #12921 ....

@bep bep closed this as completed Oct 13, 2024
Copy link

github-actions bot commented Nov 4, 2024

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 4, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants