1e2736ff6SVladimir Kotal[![](https://images.microbadger.com/badges/image/opengrok/docker.svg)](https://microbadger.com/images/opengrok/docker "Get your own image badge on microbadger.com") 2e2736ff6SVladimir Kotal[![](https://images.microbadger.com/badges/version/opengrok/docker.svg)](https://microbadger.com/images/opengrok/docker "Get your own version badge on microbadger.com") 3e2736ff6SVladimir Kotal 41106ade6SVladimir Kotal# A Docker container for OpenGrok 51106ade6SVladimir Kotal 61106ade6SVladimir Kotal## OpenGrok from official source 71106ade6SVladimir Kotal 81106ade6SVladimir KotalBuilt from official source: https://github.com/oracle/opengrok/releases/ 91106ade6SVladimir Kotal 101106ade6SVladimir KotalYou can learn more about OpenGrok at http://oracle.github.io/opengrok/ 111106ade6SVladimir Kotal 121106ade6SVladimir KotalThe container is available from DockerHub at https://hub.docker.com/r/opengrok/docker/ 131106ade6SVladimir Kotal 141106ade6SVladimir Kotal## When not to use it 151106ade6SVladimir Kotal 161106ade6SVladimir KotalThis image is simple wrapper around OpenGrok environment. The indexer and the web container are **not** tuned for large workloads. 171106ade6SVladimir KotalIf you happen to have one of the following: 181106ade6SVladimir Kotal - large source data (e.g. [AOSP](https://en.wikipedia.org/wiki/Android_Open_Source_Project) or the like) 191106ade6SVladimir Kotal - stable service 201106ade6SVladimir Kotal - Source Code Management systems not supported in the image (e.g. Perforce, 211106ade6SVladimir Kotal Clearcase, etc.) 2270960cd9SVladimir Kotal 231106ade6SVladimir Kotalthen it is advisable to run OpenGrok standalone or construct your own docker 241106ade6SVladimir Kotalimage based on the official one. 251106ade6SVladimir Kotal 26f70822c2SVladimir Kotal## Additional info about the image 271106ade6SVladimir Kotal 281106ade6SVladimir Kotal* Tomcat 9 291106ade6SVladimir Kotal* JRE 8 (Required for Opengrok 1.0+) 301106ade6SVladimir Kotal* Configurable mirroring/reindexing (default every 10 min) 311106ade6SVladimir Kotal 321106ade6SVladimir KotalThe mirroring step works by going through all projects and attempting to 331106ade6SVladimir Kotalsynchronize all its repositories (e.g. it will do `git pull` for Git 341106ade6SVladimir Kotalrepositories). 351106ade6SVladimir Kotal 361106ade6SVladimir KotalThe indexer/mirroring is set so that it does not log into files. 371106ade6SVladimir KotalRather, everything goes to standard (error) output. To see how the indexer 381106ade6SVladimir Kotalis doing, use the `docker logs` command. 391106ade6SVladimir Kotal 40f70822c2SVladimir Kotal### Tags and versioning 41f70822c2SVladimir Kotal 42*eea6103dSVladimir KotalEach OpenGrok release triggers creation of new Docker image. 43*eea6103dSVladimir Kotal 44*eea6103dSVladimir Kotal| Tag | Note | 45*eea6103dSVladimir Kotal| -------- |:--------------------------------------------------------| 46*eea6103dSVladimir Kotal| `latest` | tracks the latest version | 47*eea6103dSVladimir Kotal| `x.y.z` | if you want to pin against a specific version | 48*eea6103dSVladimir Kotal| `x.y` | stay on micro versions to avoid reindexing from scratch | 49f70822c2SVladimir Kotal 501106ade6SVladimir Kotal## How to run 511106ade6SVladimir Kotal 521106ade6SVladimir Kotal### From DockerHub 531106ade6SVladimir Kotal 541106ade6SVladimir Kotal docker run -d -v <path/to/your/src>:/opengrok/src -p 8080:8080 opengrok/docker:latest 551106ade6SVladimir Kotal 561106ade6SVladimir KotalThe container exports ports 8080 for OpenGrok. 571106ade6SVladimir Kotal 581106ade6SVladimir KotalThe volume mounted to `/opengrok/src` should contain the projects you want to make searchable (in sub directories). You can use common revision control checkouts (git, svn, etc...) and OpenGrok will make history and blame information available. 591106ade6SVladimir Kotal 601106ade6SVladimir KotalBy default, the index will be rebuild every ten minutes. You can adjust this 611106ade6SVladimir Kotaltime (in minutes) by passing the `REINDEX` environment variable: 621106ade6SVladimir Kotal 631106ade6SVladimir Kotal docker run -d -e REINDEX=30 -v <path/to/your/src>:/opengrok/src -p 8080:8080 opengrok/docker:latest 641106ade6SVladimir Kotal 651106ade6SVladimir KotalSetting `REINDEX` to `0` will disable automatic indexing. You can manually trigger an reindex using docker exec: 661106ade6SVladimir Kotal 671106ade6SVladimir Kotal docker exec <container> /scripts/index.sh 681106ade6SVladimir Kotal 691106ade6SVladimir KotalSetting `INDEXER_OPT` could pass extra options to opengrok-indexer. For example, you can run with: 701106ade6SVladimir Kotal 711106ade6SVladimir Kotal docker run -d -e INDEXER_OPT="-i d:vendor" -v <path/to/your/src>:/opengrok/src -p 8080:8080 opengrok/docker:latest 721106ade6SVladimir Kotal 731106ade6SVladimir KotalTo remove all the `*/vendor/*` files from the index. You can check the indexer options on 741106ade6SVladimir Kotal 751106ade6SVladimir Kotalhttps://github.com/oracle/opengrok/wiki/Python-scripts-transition-guide 761106ade6SVladimir Kotal 771106ade6SVladimir KotalTo avoid the mirroring step, set the `NOMIRROR` variable to non-empty value. 781106ade6SVladimir Kotal 791106ade6SVladimir Kotal## OpenGrok Web-Interface 801106ade6SVladimir Kotal 811106ade6SVladimir KotalThe container has OpenGrok as default web app installed (accessible directly from `/`). With the above container setup, you can find it running on 821106ade6SVladimir Kotal 831106ade6SVladimir Kotalhttp://localhost:8080/ 841106ade6SVladimir Kotal 851106ade6SVladimir KotalThe first reindex will take some time to finish. Subsequent reindex will be incremental so will take signigicantly less time. 861106ade6SVladimir Kotal 871106ade6SVladimir Kotal### Build image locally 881106ade6SVladimir Kotal 891106ade6SVladimir KotalIf you want to do your own development, you can build the image yourself: 901106ade6SVladimir Kotal 916670a14aSVladimir Kotal mvn -DskipTests=true clean package && \ 921106ade6SVladimir Kotal docker build -t opengrok-dev . 931106ade6SVladimir Kotal 941106ade6SVladimir KotalThen run the container: 951106ade6SVladimir Kotal 961106ade6SVladimir Kotal docker run -d -v <path/to/your/src>:/opengrok/src -p 8080:8080 opengrok-dev 971106ade6SVladimir Kotal 981106ade6SVladimir Kotal## Inspecting the container 991106ade6SVladimir Kotal 1001106ade6SVladimir KotalYou can get inside a container using the [command below](https://docs.docker.com/engine/reference/commandline/exec/): 1011106ade6SVladimir Kotal 1021106ade6SVladimir Kotal``` 1031106ade6SVladimir Kotaldocker exec -it <container> bash 1041106ade6SVladimir Kotal``` 1051106ade6SVladimir Kotal 1061106ade6SVladimir KotalEnjoy. 107