Creation of docker-compose.yaml from a Hugomod template

Hi, I want to be able to deploy using docker compose a website with this theme: https://github.com/razonyang/hugo-theme-bootstrap-skeleton on my private server. I find myself unable to create such a docker-compose.yaml to do so, can someone please help me with it?

I have something like so:

version: '3.8'
services:
  private-website-server:
      build:
         context: .
         dockerfile: Dockerfile
      image: hugomods/hugo:latest
      container_name: private-website-server
      restart: always
      command: "hugo server"
      ports:
        - "6969:1313"
      expose:
        - 6969
      volumes:
         - .:/src

Unfortunately, it shows a crazy error message:

2023-08-22 16:38:41 WARN  no such image can be found in page resources and the static folder: images/logo.webp
2023-08-22 16:38:41 WARN  no such image can be found in page resources and the static folder: images/profile.webp
2023-08-22 16:38:44 ERROR render of "page" failed: "/tmp/hugo_cache/modules/filecache/modules/pkg/mod/github.com/razonyang/hugo-theme-bootstrap@v1.2.2/layouts/_default/baseof.html:12:8": execute of template failed: template: docs/single.html:12:8: executing "docs/single.html" at <partial "head.html" .>: error calling partial: partial "head.html" timed out after 30s. This is most likely due to infinite recursion. If this is just a slow template, you can try to increase the 'timeout' config setting.
2023-08-22 16:38:44 ERROR render of "page" failed: "/tmp/hugo_cache/modules/filecache/modules/pkg/mod/github.com/razonyang/hugo-theme-bootstrap@v1.2.2/layouts/_default/baseof.html:12:8": execute of template failed: template: _default/single.html:12:8: executing "_default/single.html" at <partial "head.html" .>: error calling partial: partial "head.html" timed out after 30s. This is most likely due to infinite recursion. If this is just a slow template, you can try to increase the 'timeout' config setting.
2023-08-22 16:38:44 ERROR render of "page" failed: "/tmp/hugo_cache/modules/filecache/modules/pkg/mod/github.com/razonyang/hugo-theme-bootstrap@v1.2.2/layouts/_default/baseof.html:12:8": execute of template failed: template: _default/contact.html:12:8: executing "_default/contact.html" at <partial "head.html" .>: error calling partial: partial "head.html" timed out after 30s. This is most likely due to infinite recursion. If this is just a slow template, you can try to increase the 'timeout' config setting.
2023-08-22 16:38:44 Built in 74324 ms
2023-08-22 16:38:44 Error: error building site: render: failed to render pages: render of "page" failed: "/tmp/hugo_cache/modules/filecache/modules/pkg/mod/github.com/razonyang/hugo-theme-bootstrap@v1.2.2/layouts/_default/baseof.html:12:8": execute of template failed: template: docs/single.html:12:8: executing "docs/single.html" at <partial "head.html" .>: error calling partial: partial "head.html" timed out after 30s. This is most likely due to infinite recursion. If this is just a slow template, you can try to increase the 'timeout' config setting.

Thank you.

Couldn’t reproduce it, you can consider increacing the timeout in configuration file if there are a lot of pages on your site.

Btw, you may need to change the command as hugo server -p 6969 --bind 0.0.0.0, since the URLs is related to the baseURL (localhost:1313 by default on hugo server), otherwise you may encounter unexpected problems. You’ll need to adjust the ports as well.

version: '3.8'
services:
  private-website-server:
      image: hugomods/hugo:latest
      container_name: private-website-server
      restart: always
      command: "hugo server -p 6969 --bind 0.0.0.0"
      ports:
        - "6969:6969"
      expose:
        - 6969
      volumes:
         - .:/src

image

1 Like

Good day to you @razon, can you show me what are the steps you took to make it happen? I don’t have any pages on the theme, it is literally just what is on the GitHub: GitHub - razonyang/hugo-theme-bootstrap-skeleton: The starter template of Hugo Bootstrap Theme.

Hi, I’m using the same template for testing.

Clone the repo

$ cd /tmp
$ git clone git@github.com:razonyang/hugo-theme-bootstrap-skeleton.git
$ cd hugo-theme-bootstrap-skeleton

Install dependencies

$ npm ci

Docker compose (the compose’s config is same as I posted above)

$ vim docker-compose.yml

$ docker-compose up

It takes less than 2s to start the server on my machine, but according to your logs, Hugo took a long time to start the server.

1 Like

@razon Hi Razon

Thank you for your reply.

I followed exactly as what you had explained in your post but I still encounter this error:

MYCOMPUTER MINGW64 /f/website
$ git clone git@github.com:razonyang/hugo-theme-bootstrap-skeleton.git
Cloning into 'hugo-theme-bootstrap-skeleton'...
remote: Enumerating objects: 7347, done.
remote: Counting objects: 100% (737/737), done.
remote: Compressing objects: 100% (262/262), done.
remote: Total 7347 (delta 442), reused 541 (delta 346), pack-reused 6610
Receiving objects: 100% (7347/7347), 4.60 MiB | 3.65 MiB/s, done.
Resolving deltas: 100% (3616/3616), done.
Updating files: 100% (78/78), done.

MYCOMPUTER MINGW64 /f/website
$ cd hugo-theme-bootstrap-skeleton

MYCOMPUTER MINGW64 /f/website/hugo-theme-bootstrap-skeleton (main)
$ npm ci
npm WARN deprecated @braintree/sanitize-url@3.1.0: Potential XSS vulnerability patched in v6.0.0.

added 514 packages, and audited 515 packages in 2m

47 packages are looking for funding
  run `npm fund` for details

13 vulnerabilities (2 moderate, 11 high)

To address issues that do not require attention, run:
  npm audit fix

To address all issues (including breaking changes), run:
  npm audit fix --force

Run `npm audit` for details.

MYCOMPUTER MINGW64 /f/website/hugo-theme-bootstrap-skeleton (main)
$ vim docker-compose.yaml

MYCOMPUTER MINGW64 /f/website/hugo-theme-bootstrap-skeleton (main)
$ docker compose up
Network hugo-theme-bootstrap-skeleton_default  Creating
Network hugo-theme-bootstrap-skeleton_default  Created
Container private-website-server  Creating
Container private-website-server  Created
Attaching to private-website-server
private-website-server  | hugo: downloading modules …
private-website-server  | hugo: collected modules in 5147 ms
private-website-server  | Watching for changes in /src/{archetypes,assets,content,layouts,package.hugo.json,package.json,static}
private-website-server  | Watching for config changes in /src/config/_default, /src/go.mod
private-website-server  | Start building sites …
private-website-server  | hugo v0.117.0-b2f0696cad918fb61420a6aff173eb36662b406e+extended linux/amd64 BuildDate=2023-08-07T12:49:48Z
private-website-server  |
private-website-server  | ERROR render of "page" failed: "/tmp/hugo_cache/modules/filecache/modules/pkg/mod/github.com/razonyang/hugo-theme-bootstrap@v1.2.2/layouts/_default/baseof.html:12:8": execute of template failed: template: _default/single.html:12:8: executing "_default/single.html" at <partial "head.html" .>: error calling partial: partial "head.html" timed out after 30s. This is most likely due to infinite recursion. If this is just a slow template, you can try to increase the 'timeout' config setting.
private-website-server  | ERROR render of "page" failed: "/tmp/hugo_cache/modules/filecache/modules/pkg/mod/github.com/razonyang/hugo-theme-bootstrap@v1.2.2/layouts/_default/baseof.html:12:8": execute of template failed: template: docs/single.html:12:8: executing "docs/single.html" at <partial "head.html" .>: error calling partial: partial "head.html" timed out after 30s. This is most likely due to infinite recursion. If this is just a slow template, you can try to increase the 'timeout' config setting.
private-website-server  | Built in 83466 ms
private-website-server  | Error: error building site: render: failed to render pages: render of "page" failed: "/tmp/hugo_cache/modules/filecache/modules/pkg/mod/github.com/razonyang/hugo-theme-bootstrap@v1.2.2/layouts/_default/baseof.html:12:8": execute of template failed: template: _default/single.html:12:8: executing "_default/single.html" at <partial "head.html" .>: error calling partial: partial "head.html" timed out after 30s. This is most likely due to infinite recursion. If this is just a slow template, you can try to increase the 'timeout' config setting.
private-website-server exited with code 1
private-website-server  | Watching for changes in /src/{archetypes,assets,content,layouts,package.hugo.json,package.json,static}
private-website-server  | Watching for config changes in /src/config/_default, /src/go.mod
private-website-server  | Start building sites …
private-website-server  | hugo v0.117.0-b2f0696cad918fb61420a6aff173eb36662b406e+extended linux/amd64 BuildDate=2023-08-07T12:49:48Z

Not too sure what is wrong with it, it keeps saying it goes into an infinite recursion. It is quite upsetting because I think your Theme is one of the most beautiful themes on Hugo and I would love to use it for my engineering blog.

Sorry for the lately response.

Does it work when using native Hugo command other than docker-compose? Is the docker-compose work for other themes?

From the logs, there maybe an IO performance issue on your machine.

added 514 packages, and audited 515 packages in **2m**

It takes too long to install the dependencies (2m, NPM) and build the site (Hugo). The former took 25s, and later took 8s on my Windows, Linux should be more faster. GitHub Action is about the same.