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 16bc2f6de0SVladimir KotalThis image is simple wrapper around OpenGrok environment. It is basicallyt a small appliance. The indexer and the web container are **not** tuned for large workloads. 17bc2f6de0SVladimir Kotal 181106ade6SVladimir KotalIf you happen to have one of the following: 191106ade6SVladimir Kotal - large source data (e.g. [AOSP](https://en.wikipedia.org/wiki/Android_Open_Source_Project) or the like) 201106ade6SVladimir Kotal - stable service 211106ade6SVladimir Kotal - Source Code Management systems not supported in the image (e.g. Perforce, 221106ade6SVladimir Kotal Clearcase, etc.) 23bc2f6de0SVladimir Kotal - need for authentication/authorization 24703bf669SVladimir Kotal 25bc2f6de0SVladimir Kotalthen it is advisable to run OpenGrok standalone or construct your own Docker 261106ade6SVladimir Kotalimage based on the official one. 271106ade6SVladimir Kotal 28f70822c2SVladimir Kotal## Additional info about the image 291106ade6SVladimir Kotal 301106ade6SVladimir Kotal* Tomcat 9 311106ade6SVladimir Kotal* JRE 8 (Required for Opengrok 1.0+) 321106ade6SVladimir Kotal* Configurable mirroring/reindexing (default every 10 min) 331106ade6SVladimir Kotal 341106ade6SVladimir KotalThe mirroring step works by going through all projects and attempting to 351106ade6SVladimir Kotalsynchronize all its repositories (e.g. it will do `git pull` for Git 361106ade6SVladimir Kotalrepositories). 371106ade6SVladimir Kotal 38ab135123SVladimir Kotal### Indexer logs 39ab135123SVladimir Kotal 401106ade6SVladimir KotalThe indexer/mirroring is set so that it does not log into files. 411106ade6SVladimir KotalRather, everything goes to standard (error) output. To see how the indexer 421106ade6SVladimir Kotalis doing, use the `docker logs` command. 431106ade6SVladimir Kotal 4484ed967bSVladimir Kotal### Source Code Management systems supported 4584ed967bSVladimir Kotal 4684ed967bSVladimir Kotal- Mercurial 4784ed967bSVladimir Kotal- Git 4884ed967bSVladimir Kotal- Subversion 4984ed967bSVladimir Kotal 50f70822c2SVladimir Kotal### Tags and versioning 51f70822c2SVladimir Kotal 52eea6103dSVladimir KotalEach OpenGrok release triggers creation of new Docker image. 53eea6103dSVladimir Kotal 54eea6103dSVladimir Kotal| Tag | Note | 55eea6103dSVladimir Kotal| -------- |:--------------------------------------------------------| 56eea6103dSVladimir Kotal| `latest` | tracks the latest version | 57eea6103dSVladimir Kotal| `x.y.z` | if you want to pin against a specific version | 58eea6103dSVladimir Kotal| `x.y` | stay on micro versions to avoid reindexing from scratch | 59f70822c2SVladimir Kotal 601106ade6SVladimir Kotal## How to run 611106ade6SVladimir Kotal 621106ade6SVladimir Kotal### From DockerHub 631106ade6SVladimir Kotal 641106ade6SVladimir Kotal docker run -d -v <path/to/your/src>:/opengrok/src -p 8080:8080 opengrok/docker:latest 651106ade6SVladimir Kotal 661106ade6SVladimir KotalThe container exports ports 8080 for OpenGrok. 671106ade6SVladimir Kotal 681106ade6SVladimir 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. 691106ade6SVladimir Kotal 7015936b04SVladimir Kotal## Environment Variables 711106ade6SVladimir Kotal 7215936b04SVladimir Kotal| Docker Environment Var. | Description | 7315936b04SVladimir Kotal| ----------------------- | ----------- | 7415936b04SVladimir Kotal`REINDEX: <time_in_minutes>`<br/> *Optional* *Default: 10* | Period of automatic mirroring/reindexing. Setting to `0` will disable automatic indexing. You can manually trigger an reindex using docker exec: `docker exec <container> /scripts/index.sh` 7515936b04SVladimir Kotal`INDEXER_OPT` | pass extra options to opengrok-indexer. For example, "-i d:vendor" will remove all the `*/vendor/*` files from the index. You can check the indexer options on https://github.com/oracle/opengrok/wiki/Python-scripts-transition-guide 7615936b04SVladimir Kotal`NOMIRROR` | To avoid the mirroring step, set the variable to non-empty value. 771106ade6SVladimir Kotal 7815936b04SVladimir KotalTo specify environment variable for `docker run`, use the `-e` option, e.g. `-e REINDEX=30` 791106ade6SVladimir Kotal 801106ade6SVladimir Kotal## OpenGrok Web-Interface 811106ade6SVladimir Kotal 821106ade6SVladimir KotalThe container has OpenGrok as default web app installed (accessible directly from `/`). With the above container setup, you can find it running on 831106ade6SVladimir Kotal 841106ade6SVladimir Kotalhttp://localhost:8080/ 851106ade6SVladimir Kotal 861106ade6SVladimir KotalThe first reindex will take some time to finish. Subsequent reindex will be incremental so will take signigicantly less time. 871106ade6SVladimir Kotal 88*33551f14SVladimir Kotal## Using Docker compose 89*33551f14SVladimir Kotal 90*33551f14SVladimir Kotal[Docker-compose](https://docs.docker.com/compose/install/) example: 91*33551f14SVladimir Kotal 92*33551f14SVladimir Kotal```yaml 93*33551f14SVladimir Kotalversion: "3" 94*33551f14SVladimir Kotal 95*33551f14SVladimir Kotal# More info at https://github.com/oracle/opengrok/docker/ 96*33551f14SVladimir Kotalservices: 97*33551f14SVladimir Kotal opengrok: 98*33551f14SVladimir Kotal container_name: opengrok 99*33551f14SVladimir Kotal image: opengrok/docker:latest 100*33551f14SVladimir Kotal ports: 101*33551f14SVladimir Kotal - "8080:8080/tcp" 102*33551f14SVladimir Kotal environment: 103*33551f14SVladimir Kotal REINDEX: '60' 104*33551f14SVladimir Kotal # Volumes store your data between container upgrades 105*33551f14SVladimir Kotal volumes: 106*33551f14SVladimir Kotal - '~/opengrok-src/:/opengrok/src/' 107*33551f14SVladimir Kotal``` 108*33551f14SVladimir Kotal 109*33551f14SVladimir KotalSave the file into `docker-compose.yml` and then simply run 110*33551f14SVladimir Kotal 111*33551f14SVladimir Kotal docker-compose up -d 112*33551f14SVladimir Kotal 113*33551f14SVladimir KotalEquivalent `docker run` command would look like this: 114*33551f14SVladimir Kotal 115*33551f14SVladimir Kotal```bash 116*33551f14SVladimir Kotaldocker run -d \ 117*33551f14SVladimir Kotal --name opengrok \ 118*33551f14SVladimir Kotal -p 8080:8080/tcp \ 119*33551f14SVladimir Kotal -e REINDEX="60" \ 120*33551f14SVladimir Kotal -v "~/opengrok-src/:/opengrok/src/" \ 121*33551f14SVladimir Kotal opengrok/docker:latest 122*33551f14SVladimir Kotal``` 123*33551f14SVladimir Kotal 124*33551f14SVladimir Kotal## Build image locally 1251106ade6SVladimir Kotal 1261106ade6SVladimir KotalIf you want to do your own development, you can build the image yourself: 1271106ade6SVladimir Kotal 1286670a14aSVladimir Kotal mvn -DskipTests=true clean package && \ 1291106ade6SVladimir Kotal docker build -t opengrok-dev . 1301106ade6SVladimir Kotal 1311106ade6SVladimir KotalThen run the container: 1321106ade6SVladimir Kotal 1331106ade6SVladimir Kotal docker run -d -v <path/to/your/src>:/opengrok/src -p 8080:8080 opengrok-dev 1341106ade6SVladimir Kotal 1351106ade6SVladimir Kotal## Inspecting the container 1361106ade6SVladimir Kotal 1371106ade6SVladimir KotalYou can get inside a container using the [command below](https://docs.docker.com/engine/reference/commandline/exec/): 1381106ade6SVladimir Kotal 1391106ade6SVladimir Kotal``` 1401106ade6SVladimir Kotaldocker exec -it <container> bash 1411106ade6SVladimir Kotal``` 1421106ade6SVladimir Kotal 1431106ade6SVladimir KotalEnjoy. 144