Need assistance with Hugo's official Docker image for continuous deployment

Hello,

I am trying to deploy Hugo automatically with CI/CD.

I am trying to clone a repository with `https://code.forgejo.org/actions/checkout`, this works fine.

Now I am trying to build my hugo website in the same workflow.

I am pulling the docker image of hugo `ghcr.io/gohugo/hugo`, this also works fine as a separate step, but when trying to combine the both tasks it fails with:

::error::Unable to locate executable file: ssh. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also check the file mode to verify the file is executable.

My explanation for this is that the workflow only loads the docker image, and nothing else and only has access to the `hugo` command.

Here is the section of my workflow hugo.yaml:

jobs:
  clone:
    runs-on: ...
    container:
      image: ghcr.io/gohugoio/hugo:v0.155.3@sha256:a97a8429a9226bbf8fbbc98e418723b071d9b113222a8bc947511e9b4043e58d
      credentials:
        ...
    steps:
      - name: Clone the repository
        uses: https://code.forgejo.org/actions/checkout@v6
        with:

How do I provide my container with the `hugo` command, but also make it a normal container?

I have no experience with Forgejo or Codeberg, but this workflow for GitHub Pages works great.

The live site is here:
https://jmooring.github.io/hosting-github-pages-official-docker-image/

The workflow:

  • Includes Git, Go, Dart Sass, and Node.js pre-installed in the image
  • Uses a persistent cache for downloaded modules and processed images

The persistent cache makes this workflow very efficient.

Thank you.
The workflow you provided me, kind of looks like the one I got.
I thought the Issue was that the `ssh` command was not provided in the `ghcr.io` image, but in your workflow its the same image, and you also use `actions/checkout` afterwards.

Could this also maybe be an indentation/newline issue?

Yes, but I’m checking out a public GitHub repository… ssh is not required. Additionally, I have no idea if code.forgejo.org/actions/checkout behaves differently than github.com/actions/checkout.

Add this step before checking out the repository, and test again:

- name: Setup system tools
  run: apk add --no-cache openssh-client tar

Related: https://github.com/gohugoio/hugo/issues/14502

I kind of gave up on my initial workflow with providing the `container` keyword.

What I did now is try to build my website with:

run: |
    docker run --rm ghcr.io/gohugoio/hugo

I still have issues with that :frowning: , Im not sure if I should open up another Issue.
You wrote about the docker image here Document usage of the ghcr.io/gohugoio/hugo Docker image · Issue #2727 · gohugoio/hugoDocs · GitHub and here: Improve Docker image · Issue #12885 · gohugoio/hugo · GitHub

I tried the commands you provided with docker run -v .:/site -u $(id -u):$(id -g) ....
I tried to replace site with project, but hugo always says

ERROR Unable to locate config file or config directory. Perhaps you need to create a new site.

I tried running cloning my repo to try it local, it works fine.
But when running docker run on local I get errors like

Error: error building site: failed to acquire a build lock: open /site/.hugo_build.lock: permission denied

and with –noBuildLock:

ERROR error building site: render: [en v1.0.0 guest] failed to render pages: render of "/categories" failed: "/project/themes/hugo-book/layouts/baseof.html:4:5": execute of template failed: template: list.html:4:5: executing "list.html" at <partial "docs/html-head" .>: error calling partial: "/project/themes/hugo-book/layouts/_partials/docs/html-head.html:33:32": execute of template failed: template: _partials/docs/html-head.html:33:32: executing "_partials/docs/html-head.html" at <partial "docs/links/resource-precache" $styles>: error calling partial: "/project/themes/hugo-book/layouts/_partials/docs/links/resource-precache.html:1:43": execute of template failed: template: _partials/docs/links/resource-precache.html:1:43: executing "_partials/docs/links/resource-precache.html" at <.RelPermalink>: error calling RelPermalink: open /project/resources/_gen/assets/book.scss_b807c86e8030af4cdc30edccea379f5f.json: permission denied

Was that before or after you did this…

Though with v0.156.0 you don’t have to do that anymore… tar and openssh-client are now included in the image.

After.
The issue only happends when I do run: | docker run ...

I’d like to get back to the original problem, but from your response it is unclear if you actually made the changes I suggested before your gave up on the container approach. As I mentioned above, this container setup works great for GitHub Pages:

And with v0.156.0 and later the image includes openssh-client.

Your snippet worked perfectly, thank you :mirror_ball: :tada:
Maybe the issue was that openssh-client is installing the ssh binary under /sbin and I needed the option --user: root… But I’m not sure

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.