[SOLVED] "/bin/sh: hugo: not found" in Docker container

I’m using Docker for building Hugo sites with GitLab CI. The Dockerfile can be found here: https://github.com/dettmering/hugo-build/blob/master/Dockerfile and the Docker image here: https://hub.docker.com/r/dettmering/hugo-build/

This worked perfectly until I decided to give the new extended version 0.44 a try. The only thing I changed was the name of the tarball so the _extended_0.44 tarball is downloaded.

Now, when I run the Docker container, I get /bin/sh: hugo: not found, even though the hugo binary is in the correct folder.

What could be the problem?

Thank you!
``

This is the Docker file which I use.

https://hub.docker.com/r/joergklein/hugo

FROM debian:stable

# Install pygments (for syntax highlighting) 
RUN apt-get -qq update \
	&& DEBIAN_FRONTEND=noninteractive apt-get -qq install -y --no-install-recommends python-pygments git ca-certificates asciidoc curl \
	&& rm -rf /var/lib/apt/lists/*

# Download and install hugo
ENV HUGO_VERSION 0.44
ENV HUGO_BINARY hugo_${HUGO_VERSION}_Linux-64bit.deb

#ADD https://github.com/spf13/hugo/releases/download/v${HUGO_VERSION}/${HUGO_BINARY} /tmp/hugo.deb
RUN curl -sL -o /tmp/hugo.deb \
    https://github.com/spf13/hugo/releases/download/v${HUGO_VERSION}/${HUGO_BINARY} && \
    dpkg -i /tmp/hugo.deb && \
    rm /tmp/hugo.deb && \
    mkdir /usr/share/blog

WORKDIR /usr/share/blog

# Expose default hugo port
EXPOSE 1313

# Automatically build site
ONBUILD ADD site/ /usr/share/blog
ONBUILD RUN hugo -d /usr/share/nginx/html/

# By default, serve site
ENV HUGO_BASE_URL http://localhost:1313
CMD hugo server -b ${HUGO_BASE_URL} --bind=0.0.0.0

my .gitlab-ci.yml

image: joergklein/hugo:latest

before_script:
  - apt-get update
  - apt-get --yes --force-yes install git ssh rsync
  - git submodule update --init --recursive

stages:
    - test
    - deploy

test:
  stage: test
  script:
  - hugo
  except:
  - master

deploy:
  stage: deploy
  script:
    - hugo
    - mkdir "${HOME}/.ssh"
    - echo "${SSH_HOST_KEY}" > "${HOME}/.ssh/known_hosts"
    - echo "${SSH_PRIVATE_KEY}" > "${HOME}/.ssh/id_rsa"
    - chmod 700 "${HOME}/.ssh/id_rsa"
    - rsync -hrvz --delete --exclude=_ public/ user@example.com:www/developer/

  artifacts:
    paths:
    - public
  only:
  - master

Thank you. For me, it also works perfectly with 0.44 if I’m not using the new extended version of Hugo that doesn’t include the SASS compiler. The problem arises only if I’m using the new extended version hugo_extended_0.44_Linux-64bit.tar.gz

Ok, I’ve gotten a bit further. file hugo returns

hugo: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=7621f50844b0494c9fa7846a9e1366892aacf6c8, stripped

So apparently this can’t be run on alpine linux, which is a pity as I was happy with the extremely small Docker image of 8MB :frowning: … Need to switch to a different distro then.

For future reference: https://github.com/gohugoio/hugo/issues/3382

Maybe this can be fixed…

The solution was to install libstdc++, see the current working Dockerfile: https://github.com/dettmering/hugo-build/blob/3275b1c4eb90abf7f5cab7107f7e6c894eb74505/Dockerfile

3 Likes