Build project in GitLab

Hello,

i am trying to build project on Gitlab.
I followed this post https://discourse.gohugo.io/t/the-up-to-date-hugo-docker-images/43293

When i build it on my local computer everything works fine and all pages are build.

Step 1/9 : FROM docker.kpsys.cz/hugomods/hugo:exts as builder
 ---> afe30d068404
Step 2/9 : ARG HUGO_BASEURL
 ---> Using cache
 ---> 236f0cc08bdc
Step 3/9 : ENV HUGO_BASEURL=${HUGO_BASEURL}
 ---> Using cache
 ---> f702b4559c2e
Step 4/9 : COPY . /src
 ---> 28d585a796f9
Step 5/9 : RUN hugo --minify --gc --enableGitInfo
 ---> Running in 459ca0c191c1
Start building sites … 
hugo v0.118.2-da7983ac4b94d97d776d7c2405040de97e95c03d+extended linux/amd64 BuildDate=2023-08-31T11:23:51Z


                   | CS   
-------------------+------
  Pages            | 255  
  Paginator pages  |   0  
  Non-page files   |   0  
  Static files     | 425  
  Processed images |   0  
  Aliases          |   3  
  Sitemaps         |   1  
  Cleaned          |   2  

Total in 2116 ms
Removing intermediate container 459ca0c191c1
 ---> 16f9c9b46cac

Step 6/9 : FROM docker.kpsys.cz/hugomods/hugo:nginx
 ---> e6c192db78e0
Step 7/9 : COPY --from=builder /src/public /site
 ---> Using cache
 ---> 7210181c1b9d
Step 8/9 : ENTRYPOINT ["/docker-entrypoint.sh"]
 ---> Using cache
 ---> e05baf5eb4fa
Step 9/9 : CMD ["nginx", "-g", "daemon off;"]
 ---> Using cache
 ---> dd16cc5c742d

Successfully built dd16cc5c742d
Successfully tagged docker-push.kpsys.cz/kpsys/verbis-help:latest
Creating container…
Container Id: fead1ee3f5a8d992cf80d34a4dbd52940da1af37f78186050bf7d408444e9951
Container name: '/flamboyant_mestorf'
Starting container '/flamboyant_mestorf'
'<unknown> Dockerfile: Dockerfile' has been deployed successfully.

When I push project to GitLab and i am trying to build it there it build much less pages than on localhost. There are also some warnings which i dont have on localhost during build

Please can you help. Do you have any idea what is going wrong?

Thx
Honza

Picture is not vissible well, se here is what is gitlab saying

#0 building with "default" instance using docker driver

#1 [internal] load .dockerignore
#1 transferring context: 2B done
#1 DONE 0.0s

#2 [internal] load build definition from Dockerfile
#2 transferring dockerfile: 1.03kB done
#2 DONE 0.0s

#3 [internal] load metadata for docker.kpsys.cz/hugomods/hugo:exts
#3 DONE 0.0s

#4 [internal] load metadata for docker.kpsys.cz/hugomods/hugo:nginx
#4 DONE 0.0s

#5 [stage-1 1/2] FROM docker.kpsys.cz/hugomods/hugo:nginx@sha256:2394b0571c3c7eec4483cf86ca16b24ba03cced5958bc12072cd3f9e97220ad9
#5 CACHED

#6 [builder 1/3] FROM docker.kpsys.cz/hugomods/hugo:exts@sha256:b21265ed17b3f670182b9c648fa8d0be9f5b472726858d4941ded55e8b7c4f51
#6 CACHED

#7 [internal] load build context
#7 transferring context: 490.89MB 2.5s done
#7 DONE 2.5s

#8 [builder 2/3] COPY . /src
#8 DONE 0.7s

#9 [builder 3/3] RUN hugo --minify --gc --enableGitInfo
#9 0.638 Start building sites … 
#9 0.638 hugo v0.118.2-da7983ac4b94d97d776d7c2405040de97e95c03d+extended linux/amd64 BuildDate=2023-08-31T11:23:51Z
#9 0.638 
#9 0.697 WARN  found no layout file for "html" for kind "page": You should create a template file which matches Hugo Layouts Lookup Rules for this combination.
#9 0.743 WARN  found no layout file for "headers" for kind "home": You should create a template file which matches Hugo Layouts Lookup Rules for this combination.
#9 0.743 WARN  found no layout file for "redirects" for kind "home": You should create a template file which matches Hugo Layouts Lookup Rules for this combination.
#9 0.790 WARN  found no layout file for "sitemap" for kind "section": You should create a template file which matches Hugo Layouts Lookup Rules for this combination.
#9 0.896 
#9 0.896                    | CS   
#9 0.896 -------------------+------
#9 0.896   Pages            |  24  
#9 0.896   Paginator pages  |   0  
#9 0.896   Non-page files   |   0  
#9 0.896   Static files     | 335  
#9 0.896   Processed images |   0  
#9 0.896   Aliases          |   0  
#9 0.896   Sitemaps         |   1  
#9 0.896   Cleaned          |   0  
#9 0.896 
#9 0.896 Total in 262 ms
#9 DONE 1.1s

#10 [stage-1 2/2] COPY --from=builder /src/public /site
#10 DONE 0.3s

#11 exporting to image
#11 exporting layers
#11 exporting layers 0.6s done
#11 writing image sha256:56b1ae16c9836a1683cbd03d0b78c93015182d650fe9802002bafd2be47f4f15 done
#11 naming to docker-push.kpsys.cz/kpsys/verbis-help done
#11 DONE 0.6s
WARNING: buildx: git was not found in the system. Current commit information was not captured by the build
e[32;1m$ docker login ${DOCKER_HUB_URL} -u ${DOCKER_USERNAME} -p ${DOCKER_PASSWORD}e[0;m
WARNING! Using --password via the CLI is insecure. Use --password-stdin.
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store

Login Succeeded
e[32;1m$ docker push ${DOCKER_IMAGE}e[0;m
Using default tag: latest
The push refers to repository [docker-push.kpsys.cz/kpsys/verbis-help]

It seems that missing theme files on GitLab deployment, add a Docker command in Dockerfile to install the theme, for example, when installing the theme as Git submodule, add the following command above the hugo command.

RUN git submodule update --init --recursive

Hello, thx for reply. I tryied what you suggested and this one doesnt help

it looks like this now

#####################################################################
#                            Build Stage                            #
#####################################################################
FROM docker.kpsys.cz/hugomods/hugo:exts as builder
# Base URL
ARG HUGO_BASEURL
ENV HUGO_BASEURL=${HUGO_BASEURL}
# Build site
COPY . /src
RUN git submodule update --init --recursive
RUN hugo --minify --gc --enableGitInfo
# Set the fallback 404 page if defaultContentLanguageInSubdir is enabled, please replace the `en` with your default language code.
# RUN cp ./public/en/404.html ./public/404.html

#####################################################################
#                            Final Stage                            #
#####################################################################
FROM docker.kpsys.cz/hugomods/hugo:nginx
# Copy the generated files to keep the image as small as possible.
COPY --from=builder /src/public /site

ENTRYPOINT ["/docker-entrypoint.sh"]

CMD ["nginx", "-g", "daemon off;"]

It depends how do you install the theme, could you share your repo if possible?

Repo is here: Verbis Help

You have to switch to Build branch.

It’s slow to clone the repo, but I’ve looked into the source code, the theme was published as a NPM package, you should install the theme via:

RUN npm install

And then you should be able to build the site via hugo ....

thx its at least gave me direction where to go.

same issue i had when i was trying to build it with different image with npm.
Could be problem that on my local machine i am building it on windows and here its build in linux?

This is what UI sad me that is the problem.

The error message you provided indicates that there was a problem installing the Hugo binary using the Hugo Installer. The specific error is "An error occured while verifiy the binary health. Details: spawn node_modules/.bin/hugo/hugo ENOENT". This means that the Hugo binary could not be found at the specified location.

There are a few possible reasons for this error:

The Hugo binary was not downloaded successfully.
The Hugo binary was downloaded but is corrupted.
The Hugo binary was extracted to the wrong location.
The Hugo binary is missing dependencies.
To troubleshoot this error, you can try the following:

Make sure that the Hugo Installer has permission to download and extract the Hugo binary.
Try running the Hugo Installer again.
Try downloading the Hugo binary manually and placing it in the correct location.
Make sure that the Hugo binary has all of its dependencies installed.
If you are still having trouble, you can try searching for help online or contacting the Hugo support team.

Here are some additional tips for troubleshooting npm install errors:

Make sure that you are using the latest version of npm.
Try running npm install with the -v flag to enable verbose logging. This can help you to identify the specific cause of the error.
Try running npm install with the -f flag to force npm to reinstall all packages.
If you are still having trouble, try searching for help online or contacting the package developer.

The site installs Hugo via NPM, see Blame · package.json · build · verbis / Verbis Help · GitLab

If you’re using the Docker images to build the site, you don’t need to the postinstall script, see how to disable the on node.js - npm: disable postinstall script for package - Stack Overflow.

Thx a lot, it helped. Just IDK why but for me worked do disable all scripts with

npm install --ignore-scripts