xref: /OpenGrok/docker/README.md (revision 499a02c9638772cdcb5be169c5de6b8514d6d4aa)
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
16a391beadSAdam HornacekThis image is simple wrapper around OpenGrok environment. It is basically 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:
1964c0a233SShenghan Gao
201106ade6SVladimir Kotal  - large source data (e.g. [AOSP](https://en.wikipedia.org/wiki/Android_Open_Source_Project) or the like)
211106ade6SVladimir Kotal  - stable service
221106ade6SVladimir Kotal  - Source Code Management systems not supported in the image (e.g. Perforce,
231106ade6SVladimir Kotal    Clearcase, etc.)
24bc2f6de0SVladimir Kotal  - need for authentication/authorization
25703bf669SVladimir Kotal
26bc2f6de0SVladimir Kotalthen it is advisable to run OpenGrok standalone or construct your own Docker
271106ade6SVladimir Kotalimage based on the official one.
281106ade6SVladimir Kotal
29f70822c2SVladimir Kotal## Additional info about the image
301106ade6SVladimir Kotal
31fe0c622fSAdam Hornacek* Tomcat 10
321c8c7ecbSVladimir Kotal* JRE 11
331106ade6SVladimir Kotal* Configurable mirroring/reindexing (default every 10 min)
341106ade6SVladimir Kotal
351106ade6SVladimir KotalThe mirroring step works by going through all projects and attempting to
36*499a02c9S45hvnLsynchronize all its repositories (e.g. it will do `git pull --ff-only` for Git
371106ade6SVladimir Kotalrepositories).
381106ade6SVladimir Kotal
39d7281829SVladimir KotalProjects are enabled in this setup and there is no way how to change that.
40d7281829SVladimir Kotal
41ab135123SVladimir Kotal### Indexer logs
42ab135123SVladimir Kotal
431106ade6SVladimir KotalThe indexer/mirroring is set so that it does not log into files.
441106ade6SVladimir KotalRather, everything goes to standard (error) output. To see how the indexer
451106ade6SVladimir Kotalis doing, use the `docker logs` command.
461106ade6SVladimir Kotal
4784ed967bSVladimir Kotal### Source Code Management systems supported
4884ed967bSVladimir Kotal
4984ed967bSVladimir Kotal- Mercurial
5084ed967bSVladimir Kotal- Git
5184ed967bSVladimir Kotal- Subversion
5284ed967bSVladimir Kotal
53f70822c2SVladimir Kotal### Tags and versioning
54f70822c2SVladimir Kotal
55eea6103dSVladimir KotalEach OpenGrok release triggers creation of new Docker image.
56eea6103dSVladimir Kotal
57eea6103dSVladimir Kotal| Tag      | Note                                                    |
58eea6103dSVladimir Kotal| -------- |:--------------------------------------------------------|
59eea6103dSVladimir Kotal| `latest` | tracks the latest version                               |
60eea6103dSVladimir Kotal| `x.y.z`  | if you want to pin against a specific version           |
61eea6103dSVladimir Kotal| `x.y`    | stay on micro versions to avoid reindexing from scratch |
62f70822c2SVladimir Kotal
631106ade6SVladimir Kotal## How to run
641106ade6SVladimir Kotal
651106ade6SVladimir Kotal### From DockerHub
661106ade6SVladimir Kotal
671106ade6SVladimir Kotal    docker run -d -v <path/to/your/src>:/opengrok/src -p 8080:8080 opengrok/docker:latest
681106ade6SVladimir Kotal
691106ade6SVladimir KotalThe container exports ports 8080 for OpenGrok.
701106ade6SVladimir Kotal
711106ade6SVladimir 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.
721106ade6SVladimir Kotal
7315936b04SVladimir Kotal## Environment Variables
741106ade6SVladimir Kotal
75e2dc7a48SVladimir Kotal| Docker Environment Var. | Default value | Description |
76e2dc7a48SVladimir Kotal| ----------------------- | ------------- | ----------- |
77e2dc7a48SVladimir Kotal`REINDEX` | 10 | Period of automatic mirroring/reindexing in minutes. Setting to `0` will disable automatic indexing. You can manually trigger an reindex using docker exec: `docker exec <container> /scripts/index.sh`
7856945407SVladimir Kotal`INDEXER_FLAGS` | `-H -P -S -G` | allows to override indexer flags
79e2dc7a48SVladimir Kotal`INDEXER_OPT` | empty | 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
80e2dc7a48SVladimir Kotal`NOMIRROR` | empty | To avoid the mirroring step, set the variable to non-empty value.
81e2dc7a48SVladimir Kotal`URL_ROOT` | `/` | Override the sub-URL that OpenGrok should run on.
82b2d29daeSVladimir Kotal`WORKERS` | number of CPUs in the container | number of workers to use for syncing
831106ade6SVladimir Kotal
8415936b04SVladimir KotalTo specify environment variable for `docker run`, use the `-e` option, e.g. `-e REINDEX=30`
851106ade6SVladimir Kotal
861106ade6SVladimir Kotal## OpenGrok Web-Interface
871106ade6SVladimir Kotal
881106ade6SVladimir KotalThe container has OpenGrok as default web app installed (accessible directly from `/`). With the above container setup, you can find it running on
891106ade6SVladimir Kotal
901106ade6SVladimir Kotalhttp://localhost:8080/
911106ade6SVladimir Kotal
921106ade6SVladimir KotalThe first reindex will take some time to finish. Subsequent reindex will be incremental so will take signigicantly less time.
931106ade6SVladimir Kotal
9433551f14SVladimir Kotal## Using Docker compose
9533551f14SVladimir Kotal
9633551f14SVladimir Kotal[Docker-compose](https://docs.docker.com/compose/install/) example:
9733551f14SVladimir Kotal
9833551f14SVladimir Kotal```yaml
9933551f14SVladimir Kotalversion: "3"
10033551f14SVladimir Kotal
10133551f14SVladimir Kotal# More info at https://github.com/oracle/opengrok/docker/
10233551f14SVladimir Kotalservices:
10333551f14SVladimir Kotal  opengrok:
10433551f14SVladimir Kotal    container_name: opengrok
10533551f14SVladimir Kotal    image: opengrok/docker:latest
10633551f14SVladimir Kotal    ports:
10733551f14SVladimir Kotal      - "8080:8080/tcp"
10833551f14SVladimir Kotal    environment:
10933551f14SVladimir Kotal      REINDEX: '60'
11033551f14SVladimir Kotal    # Volumes store your data between container upgrades
11133551f14SVladimir Kotal    volumes:
1123db23db2SVladimir Kotal       - '~/opengrok/src/:/opengrok/src/'  # source code
1133db23db2SVladimir Kotal       - '~/opengrok/etc/:/opengrok/etc/'  # folder contains configuration.xml
1143db23db2SVladimir Kotal       - '~/opengrok/data/:/opengrok/data/'  # index and other things for source code
11533551f14SVladimir Kotal```
11633551f14SVladimir Kotal
11733551f14SVladimir KotalSave the file into `docker-compose.yml` and then simply run
11833551f14SVladimir Kotal
11933551f14SVladimir Kotal    docker-compose up -d
12033551f14SVladimir Kotal
12133551f14SVladimir KotalEquivalent `docker run` command would look like this:
12233551f14SVladimir Kotal
12333551f14SVladimir Kotal```bash
12433551f14SVladimir Kotaldocker run -d \
12533551f14SVladimir Kotal    --name opengrok \
12633551f14SVladimir Kotal    -p 8080:8080/tcp \
12733551f14SVladimir Kotal    -e REINDEX="60" \
1280b7e6c83SAdam Hornáček    -v ~/opengrok-src/:/opengrok/src/ \
1290b7e6c83SAdam Hornáček    -v ~/opengrok-etc/:/opengrok/etc/ \
1300b7e6c83SAdam Hornáček    -v ~/opengrok-data/:/opengrok/data/ \
13133551f14SVladimir Kotal    opengrok/docker:latest
13233551f14SVladimir Kotal```
13333551f14SVladimir Kotal
13433551f14SVladimir Kotal## Build image locally
1351106ade6SVladimir Kotal
1361106ade6SVladimir KotalIf you want to do your own development, you can build the image yourself:
1371106ade6SVladimir Kotal
138b3440527SVladimir Kotal    git clone https://github.com/oracle/opengrok.git
139b3440527SVladimir Kotal    cd opengrok
1401106ade6SVladimir Kotal    docker build -t opengrok-dev .
1411106ade6SVladimir Kotal
1421106ade6SVladimir KotalThen run the container:
1431106ade6SVladimir Kotal
1441106ade6SVladimir Kotal    docker run -d -v <path/to/your/src>:/opengrok/src -p 8080:8080 opengrok-dev
1451106ade6SVladimir Kotal
1461106ade6SVladimir Kotal## Inspecting the container
1471106ade6SVladimir Kotal
1481106ade6SVladimir KotalYou can get inside a container using the [command below](https://docs.docker.com/engine/reference/commandline/exec/):
1491106ade6SVladimir Kotal
15064c0a233SShenghan Gao```bash
1511106ade6SVladimir Kotaldocker exec -it <container> bash
1521106ade6SVladimir Kotal```
1531106ade6SVladimir Kotal
1541106ade6SVladimir KotalEnjoy.
155