How to run opengrok in docker?

2.1k views Asked by At

I'm trying to follow this tutorial: https://hub.docker.com/r/opengrok/docker/

This is what I did:

mkdir /home/testuser/OpenGrokTest
cp -R SmallCppProject /home/testuser/OpenGrokTest/
docker pull opengrok/docker
docker run -d -v /home/testuser/OpenGrokTest/:/opengrok/src -p 8080:8080 opengrok/docker:latest

Now I can access opengrok using localhost:8080 and it is there:

enter image description here

However, as you can see there is nothing. The project is very small (just 5 cpp files) and I also waited ~15 minutes "just in case" but nothing changed.

I feel this is a very simple problem but tutorial is not mentioning any additional steps, so I don't know what's wrong.

2

There are 2 answers

0
LLL On BEST ANSWER

I've solved this 5 minutes after I've posted the question ... but I believe this might be useful for someone in future because it's quite a trap, so I will leave it. There was nothing wrong with opengrok tutorial, the problem was inside my SmallCppProject. It had .git directory and inside that directory there were relative symlinks to repo. Those symlinks were broken because when I've copied the project the directory was changed. Apparently this was a problem because after removing .git directory everything is fine now. Although I think opengrok should be "prepared" for such things and ignore broken links.

Edit: Actually this was not about broken symlinks, it's about .git directory in general, so there is clearly something wrong with latest opengrok image for docker. Current version is 1.7.2 and in general if I just put sources then opengrok works, however if I add those sources to git then opengrok can't inititalize.

0
Wood On

If you look at your log carefully, it may says that OpenGrok failed to sync your local git repository with remote git repository due to lack of git key or git username and password.

OpenGrok can automatically execute git pull if your source cantains git folder, and keep your git repository up to date. But if there's no git key or username/password configured, it simply log the error and skip indexing the project, which I think is not a good design.

The right solution is to tell OpenGrok to disable auto sync.

Open the cli window of the docker container, cd to "/opengrok/etc". Inside this folder, there exists a mirror.yml file. execute the folling command:

echo "project:
  .* :
    disabled: true
">mirror.yml

and restart the container.

OpenGrok will ignore the sync of all project that contains .git folder. If you just want to disable the auto sync of a certain project, replace ".*" to the project name that you want to ignore.

Edit:

Start opengrok docker container with NOMIRROR="yes" would simply solve the problem. In your case: run the following command:

docker run -d -v /home/testuser/OpenGrokTest/:/opengrok/src -p 8080:8080 -e NOMIRROR="yes" opengrok/docker:latest