# Build project in GitLab

**URL:** <https://discourse.gohugo.io/t/build-project-in-gitlab/46330>\
**Category:** support\
**Created:** [September 21, 2023, 12:47pm UTC](https://discourse.gohugo.io/t/build-project-in-gitlab/46330 "2023-09-21T12:47:06Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![stefic](https://avatars.discourse-cdn.com/v4/letter/s/49beb7/32.png) [@stefic](https://discourse.gohugo.io/u/stefic)\
**Post date:** [September 21, 2023, 12:47pm UTC](https://discourse.gohugo.io/t/build-project-in-gitlab/46330/1 "2023-09-21T12:47:06Z")

</div>

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](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.

```auto
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

 ![gitlab](https://canada1.discourse-cdn.com/flex036/uploads/gohugo/original/3X/7/5/750a20afc7477f8533ea07259609266f03433658.png)

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

Thx  
Honza

---

<div class="post-metadata">

**Author:** ![stefic](https://avatars.discourse-cdn.com/v4/letter/s/49beb7/32.png) [@stefic](https://discourse.gohugo.io/u/stefic)\
**Post date:** [September 21, 2023, 12:49pm UTC](https://discourse.gohugo.io/t/build-project-in-gitlab/46330/2 "2023-09-21T12:49:47Z")

</div>

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

```auto
#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]

```

---

<div class="post-metadata">

**Author:** ![razon](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/razon/32/14882_2.png) [@razon](https://discourse.gohugo.io/u/razon)\
**Post date:** [September 21, 2023, 1:38pm UTC](https://discourse.gohugo.io/t/build-project-in-gitlab/46330/3 "2023-09-21T13:38:11Z")

</div>

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.

```plaintext
RUN git submodule update --init --recursive

```

---

<div class="post-metadata">

**Author:** ![stefic](https://avatars.discourse-cdn.com/v4/letter/s/49beb7/32.png) [@stefic](https://discourse.gohugo.io/u/stefic)\
**Post date:** [September 21, 2023, 1:51pm UTC](https://discourse.gohugo.io/t/build-project-in-gitlab/46330/4 "2023-09-21T13:51:50Z")

</div>

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

 ![dockerfile](https://canada1.discourse-cdn.com/flex036/uploads/gohugo/original/3X/5/0/50f26b43a6148fa59001b1ae1b2412cb27841ebf.png)

it looks like this now

```auto
#####################################################################
# 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;"]

```

---

<div class="post-metadata">

**Author:** ![razon](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/razon/32/14882_2.png) [@razon](https://discourse.gohugo.io/u/razon)\
**Post date:** [September 21, 2023, 1:57pm UTC](https://discourse.gohugo.io/t/build-project-in-gitlab/46330/5 "2023-09-21T13:57:04Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![stefic](https://avatars.discourse-cdn.com/v4/letter/s/49beb7/32.png) [@stefic](https://discourse.gohugo.io/u/stefic)\
**Post date:** [September 21, 2023, 2:01pm UTC](https://discourse.gohugo.io/t/build-project-in-gitlab/46330/6 "2023-09-21T14:01:53Z")

</div>

Repo is here: [Verbis Help](https://gitlab.kpsys.cz/verbis/verbis-help/)

You have to switch to Build branch.

---

<div class="post-metadata">

**Author:** ![razon](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/razon/32/14882_2.png) [@razon](https://discourse.gohugo.io/u/razon)\
**Post date:** [September 21, 2023, 2:26pm UTC](https://discourse.gohugo.io/t/build-project-in-gitlab/46330/7 "2023-09-21T14:26:16Z")

</div>

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:

```auto
RUN npm install

```

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

---

<div class="post-metadata">

**Author:** ![stefic](https://avatars.discourse-cdn.com/v4/letter/s/49beb7/32.png) [@stefic](https://discourse.gohugo.io/u/stefic)\
**Post date:** [September 21, 2023, 2:51pm UTC](https://discourse.gohugo.io/t/build-project-in-gitlab/46330/8 "2023-09-21T14:51:25Z")

</div>

thx its at least gave me direction where to go.

 ![npm install](https://canada1.discourse-cdn.com/flex036/uploads/gohugo/original/3X/0/7/07cec002e031d2c7090069d1343918f4b44c474c.png)

---

<div class="post-metadata">

**Author:** ![stefic](https://avatars.discourse-cdn.com/v4/letter/s/49beb7/32.png) [@stefic](https://discourse.gohugo.io/u/stefic)\
**Post date:** [September 21, 2023, 3:26pm UTC](https://discourse.gohugo.io/t/build-project-in-gitlab/46330/9 "2023-09-21T15:26:11Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![stefic](https://avatars.discourse-cdn.com/v4/letter/s/49beb7/32.png) [@stefic](https://discourse.gohugo.io/u/stefic)\
**Post date:** [September 21, 2023, 3:34pm UTC](https://discourse.gohugo.io/t/build-project-in-gitlab/46330/10 "2023-09-21T15:34:12Z")

</div>

This is what UI sad me that is the problem.

```auto
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.

```

---

<div class="post-metadata">

**Author:** ![razon](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/razon/32/14882_2.png) [@razon](https://discourse.gohugo.io/u/razon)\
**Post date:** [September 21, 2023, 5:00pm UTC](https://discourse.gohugo.io/t/build-project-in-gitlab/46330/11 "2023-09-21T17:00:19Z")

</div>

The site installs Hugo via NPM, see [Blame · package.json · build · verbis / Verbis Help · GitLab](https://gitlab.kpsys.cz/verbis/verbis-help/-/blame/build/package.json#L37)

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](https://stackoverflow.com/a/68865402).

---

<div class="post-metadata">

**Author:** ![stefic](https://avatars.discourse-cdn.com/v4/letter/s/49beb7/32.png) [@stefic](https://discourse.gohugo.io/u/stefic)\
**Post date:** [September 22, 2023, 9:17am UTC](https://discourse.gohugo.io/t/build-project-in-gitlab/46330/12 "2023-09-22T09:17:26Z")

</div>

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

```auto
npm install --ignore-scripts

```
