Hi

I've lost hope in http://opengrok.openoffice.org/ working when I need it,
and got OpenGrok running on my PC instead.

Also recently FreeBSD finally got Podman working, which now supports
FreeBSD upstream, is compatible with Docker images, and able to run Linux
Docker containers at full performance using its Linux compatibility layer
:-).

After some exploration, I got it working quite easily:

1. Make these directories:
/opt/opengrok/data - empty
/opt/opengrok/etc - empty
/opt/opengrok/openoffice-git - clean working tree with the branch you want
(eg. trunk) checked out

2. Copy the XML below and paste it as
/opt/opengrok/etc/opengrok_custom_config.xml. It was derived from
images/opengrok/opengrok_custom_config.xml in
https://gitbox.apache.org/repos/asf/openoffice-devtools.git but changed to
use 4 spaces per tab (in a way that works):

<?xml version="1.0" encoding="UTF-8"?>
<java version="1.8.0_121" class="java.beans.XMLDecoder">
  <object class="org.opengrok.indexer.configuration.Configuration"
id="Configuration0">
    <void property="projects">
      <void method="put">
        <string>openoffice-git</string>
        <object class="org.opengrok.indexer.configuration.Project">
          <void property="name">
            <string>openoffice-git</string>
          </void>
          <void property="path">
            <string>/openoffice-git</string>
          </void>
          <void property="tabSize">
            <int>4</int>
          </void>
        </object>
      </void>
    </void>
    <void id="IgnoredNames0" property="ignoredNames">
      <void id="IgnoredFiles0" property="ignoredFiles">
        <void property="items">
          <void method="add">
            <string>*.log</string>
          </void>
          <void method="add">
            <string>*.tmp</string>
          </void>
          <void method="add">
            <string>*.xls</string>
          </void>
          <void method="add">
            <string>*.jpg</string>
          </void>
          <void method="add">
            <string>*.ods</string>
          </void>
          <void method="add">
            <string>*.otp</string>
          </void>
          <void method="add">
            <string>*.ods</string>
          </void>
          <void method="add">
            <string>*.odt</string>
          </void>
          <void method="add">
            <string>*.zip</string>
          </void>
          <void method="add">
            <string>*.txt</string>
          </void>
        </void>
      </void>
    </void>
 </object>
</java>


3. podman run \
  --name opengrok-aoo \
  -d \
  --restart=unless-stopped \
  -v
/opt/opengrok/etc/opengrok_custom_config.xml:/opengrok/etc/opengrok_custom_config.xml
\
  -v /opt/opengrok/openoffice-git:/opengrok/src/openoffice-git \
  -v /opt/opengrok/data:/opengrok/data \
  -v /etc/localtime:/etc/localtime:ro \
  -e READONLY_CONFIG_FILE=/opengrok/etc/opengrok_custom_config.xml \
  -e SYNC_PERIOD_MINUTES=0 \
  -e NOMIRROR=1 \
  --network=host \
  docker.io/opengrok/docker:latest

On FreeBSD you also need:
  --os linux
  -v /compat/linux/proc:/proc
to enable Linux compatibility, and mount linprocfs from the host's
/compat/linux/proc to the container's /proc.

Note how:
- you can replace "podman" with "docker", they use the same command line
options.
- mounting into /opengrok/data persists data across restarts.
- mounting /etc/localtime is for timezone.
- I needed "--network=host" but "-p 8080:8080" should also work, still
investigating.
- the syncing and mirroring could also be left on.
- podman wants the full URL docker.io/opengrok/docker:latest instead of
opengrok/docker:latest, it's also more secure that way.
- you can monitor logs with "podman logs -f opengrok-aoo".

It works remarkably well and requires no further setup, just visit
http://localhost:8080 and start using it :-). The project will only become
visible after indexing finishes, which took about 15 minutes after first
start for me.

If it takes a long time to start indexing, that's because it uselessly
tries to contact a Perforce server (
https://github.com/oracle/opengrok/discussions/4572). It's possible to
shell into the container and uninstall the Perforce apt packages to skip
that, as described on that bug report.

Don't use your main working tree because it will index binaries and
generated files, and chown all your files to user:group 1111:1111. Use a
separate, clean working tree, with no generated files.

It's also MUCH faster locally :-), due to shorter round-trip times.

Regards
Damjan

Reply via email to