xref: /OpenGrok/docker/README.md (revision 0ddc79583fb504c2bf78c4694a3f62000998ae48)
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
36499a02c9S45hvnLsynchronize all its repositories (e.g. it will do `git pull --ff-only` for Git
371106ade6SVladimir Kotalrepositories).
381106ade6SVladimir Kotal
394810eb96SVladimir KotalProjects are enabled in this setup by default. See environment variables
404810eb96SVladimir Kotalbelow on how to change that.
41d7281829SVladimir Kotal
42ab135123SVladimir Kotal### Indexer logs
43ab135123SVladimir Kotal
441106ade6SVladimir KotalThe indexer/mirroring is set so that it does not log into files.
451106ade6SVladimir KotalRather, everything goes to standard (error) output. To see how the indexer
461106ade6SVladimir Kotalis doing, use the `docker logs` command.
471106ade6SVladimir Kotal
4884ed967bSVladimir Kotal### Source Code Management systems supported
4984ed967bSVladimir Kotal
5084ed967bSVladimir Kotal- Mercurial
5184ed967bSVladimir Kotal- Git
5284ed967bSVladimir Kotal- Subversion
5384ed967bSVladimir Kotal
54f70822c2SVladimir Kotal### Tags and versioning
55f70822c2SVladimir Kotal
56eea6103dSVladimir KotalEach OpenGrok release triggers creation of new Docker image.
57eea6103dSVladimir Kotal
58eea6103dSVladimir Kotal| Tag      | Note                                                    |
59eea6103dSVladimir Kotal| -------- |:--------------------------------------------------------|
60*0ddc7958SVladimir Kotal| `master` | corresponds to the latest commit in the OpenGrok repo   |
61*0ddc7958SVladimir Kotal| `latest` | tracks the latest [released version](https://github.com/oracle/opengrok/releases) |
62eea6103dSVladimir Kotal| `x.y.z`  | if you want to pin against a specific version           |
63eea6103dSVladimir Kotal| `x.y`    | stay on micro versions to avoid reindexing from scratch |
64f70822c2SVladimir Kotal
65*0ddc7958SVladimir KotalIf you want to stay on the bleeding edge, use the `opengrok/docker:master` image which is automatically refreshed whenever a commit is made to the OpenGrok source code repository. This allows to track the development. After all, this is what http://demo.opengrok.org/ is running.
66*0ddc7958SVladimir Kotal
67*0ddc7958SVladimir KotalFor other use cases, stick to the other image tags.
68*0ddc7958SVladimir Kotal
691106ade6SVladimir Kotal## How to run
701106ade6SVladimir Kotal
711106ade6SVladimir Kotal### From DockerHub
721106ade6SVladimir Kotal
731106ade6SVladimir Kotal    docker run -d -v <path/to/your/src>:/opengrok/src -p 8080:8080 opengrok/docker:latest
741106ade6SVladimir Kotal
751106ade6SVladimir KotalThe container exports ports 8080 for OpenGrok.
761106ade6SVladimir Kotal
771106ade6SVladimir 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.
781106ade6SVladimir Kotal
79941332aaSVladimir Kotal## Directories
80941332aaSVladimir Kotal
81941332aaSVladimir KotalThe image contains these directories:
82941332aaSVladimir Kotal
83941332aaSVladimir Kotal| Directory | Description |
84941332aaSVladimir Kotal| --------- | ----------- |
85941332aaSVladimir Kotal`/opengrok/etc` | stores the configuration for both web app and indexer
86941332aaSVladimir Kotal`/opengrok/data` | data root - index data
87941332aaSVladimir Kotal`/opengrok/src` | source root - input data
88941332aaSVladimir Kotal`/scripts` | startup script and top level configuration. Do not override unless debugging.
89941332aaSVladimir Kotal
9015936b04SVladimir Kotal## Environment Variables
911106ade6SVladimir Kotal
92e2dc7a48SVladimir Kotal| Docker Environment Var. | Default value | Description |
93e2dc7a48SVladimir Kotal| ----------------------- | ------------- | ----------- |
94b531e965SVladimir Kotal`SYNC_PERIOD_MINUTES` | 10 | Period of automatic synchronization (i.e. mirroring + reindexing) in minutes. Setting to `0` will disable periodic syncing (the sync after container startup will still be done).
957ee480e4SVladimir Kotal`INDEXER_OPT` | empty | pass **extra** options to OpenGrok Indexer. The default set of indexer options is: `--remote on -P -H -W`. 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
96e2dc7a48SVladimir Kotal`NOMIRROR` | empty | To avoid the mirroring step, set the variable to non-empty value.
97e2dc7a48SVladimir Kotal`URL_ROOT` | `/` | Override the sub-URL that OpenGrok should run on.
984810eb96SVladimir Kotal`WORKERS` | number of CPUs in the container | number of workers to use for syncing (applies only to setup with projects enabled)
99941332aaSVladimir Kotal`AVOID_PROJECTS` | empty | run in project less configuration. Set to non empty value disables projects. Also disables repository synchronization.
100f1835fddSVladimir Kotal`REST_PORT` | 5000 | TCP port where simple REST app listens for GET requests on `/reindex` to trigger manual reindex.
101f1835fddSVladimir Kotal`REST_TOKEN` | None | if set, the REST app will require this token as Bearer token in order to trigger reindex.
102b9361335SVladimir Kotal`READONLY_CONFIG_FILE` | None | if set, the configuration will be merged with configuration from this file. This is run when the container starts.
103f750ae73SVladimir Kotal`CHECK_INDEX` | None | if set, the format of the index will be checked first. **If the index is not compatible with the currently running version, the data root will be wiped out and reindex from scratch will be performed.**
1041106ade6SVladimir Kotal
1053d5852a4SVladimir KotalTo specify environment variable for `docker run`, use the `-e` option, e.g. `-e SYNC_PERIOD_MINUTES=30`
1061106ade6SVladimir Kotal
107c0e6959dSVladimir Kotal## Repository synchronization
108c0e6959dSVladimir Kotal
109c0e6959dSVladimir KotalTo get more control over repository synchronization (enabled only when projects
110c0e6959dSVladimir Kotalare enabled), the `/opengrok/etc/mirror.yml` configuration file can be modified
111c0e6959dSVladimir Kotalas per the https://github.com/oracle/opengrok/wiki/Repository-synchronization
112c0e6959dSVladimir Kotalwiki.
113c0e6959dSVladimir Kotal
1141106ade6SVladimir Kotal## OpenGrok Web-Interface
1151106ade6SVladimir Kotal
1161106ade6SVladimir KotalThe container has OpenGrok as default web app installed (accessible directly from `/`). With the above container setup, you can find it running on
1171106ade6SVladimir Kotal
1181106ade6SVladimir Kotalhttp://localhost:8080/
1191106ade6SVladimir Kotal
1201106ade6SVladimir KotalThe first reindex will take some time to finish. Subsequent reindex will be incremental so will take signigicantly less time.
1211106ade6SVladimir Kotal
12233551f14SVladimir Kotal## Using Docker compose
12333551f14SVladimir Kotal
12433551f14SVladimir Kotal[Docker-compose](https://docs.docker.com/compose/install/) example:
12533551f14SVladimir Kotal
12633551f14SVladimir Kotal```yaml
12733551f14SVladimir Kotalversion: "3"
12833551f14SVladimir Kotal
12933551f14SVladimir Kotal# More info at https://github.com/oracle/opengrok/docker/
13033551f14SVladimir Kotalservices:
13133551f14SVladimir Kotal  opengrok:
13233551f14SVladimir Kotal    container_name: opengrok
13333551f14SVladimir Kotal    image: opengrok/docker:latest
13433551f14SVladimir Kotal    ports:
13533551f14SVladimir Kotal      - "8080:8080/tcp"
13633551f14SVladimir Kotal    environment:
1373d5852a4SVladimir Kotal      SYNC_PERIOD_MINUTES: '60'
13833551f14SVladimir Kotal    # Volumes store your data between container upgrades
13933551f14SVladimir Kotal    volumes:
1403db23db2SVladimir Kotal       - '~/opengrok/src/:/opengrok/src/'  # source code
1413db23db2SVladimir Kotal       - '~/opengrok/etc/:/opengrok/etc/'  # folder contains configuration.xml
1423db23db2SVladimir Kotal       - '~/opengrok/data/:/opengrok/data/'  # index and other things for source code
14333551f14SVladimir Kotal```
14433551f14SVladimir Kotal
14533551f14SVladimir KotalSave the file into `docker-compose.yml` and then simply run
14633551f14SVladimir Kotal
14733551f14SVladimir Kotal    docker-compose up -d
14833551f14SVladimir Kotal
14933551f14SVladimir KotalEquivalent `docker run` command would look like this:
15033551f14SVladimir Kotal
15133551f14SVladimir Kotal```bash
15233551f14SVladimir Kotaldocker run -d \
15333551f14SVladimir Kotal    --name opengrok \
15433551f14SVladimir Kotal    -p 8080:8080/tcp \
1553d5852a4SVladimir Kotal    -e SYNC_PERIOD_MINUTES="60" \
1560b7e6c83SAdam Hornáček    -v ~/opengrok-src/:/opengrok/src/ \
1570b7e6c83SAdam Hornáček    -v ~/opengrok-etc/:/opengrok/etc/ \
1580b7e6c83SAdam Hornáček    -v ~/opengrok-data/:/opengrok/data/ \
15933551f14SVladimir Kotal    opengrok/docker:latest
16033551f14SVladimir Kotal```
16133551f14SVladimir Kotal
16233551f14SVladimir Kotal## Build image locally
1631106ade6SVladimir Kotal
1641106ade6SVladimir KotalIf you want to do your own development, you can build the image yourself:
1651106ade6SVladimir Kotal
166b3440527SVladimir Kotal    git clone https://github.com/oracle/opengrok.git
167b3440527SVladimir Kotal    cd opengrok
1681106ade6SVladimir Kotal    docker build -t opengrok-dev .
1691106ade6SVladimir Kotal
1701106ade6SVladimir KotalThen run the container:
1711106ade6SVladimir Kotal
1721106ade6SVladimir Kotal    docker run -d -v <path/to/your/src>:/opengrok/src -p 8080:8080 opengrok-dev
1731106ade6SVladimir Kotal
1741106ade6SVladimir Kotal## Inspecting the container
1751106ade6SVladimir Kotal
1761106ade6SVladimir KotalYou can get inside a container using the [command below](https://docs.docker.com/engine/reference/commandline/exec/):
1771106ade6SVladimir Kotal
17864c0a233SShenghan Gao```bash
1791106ade6SVladimir Kotaldocker exec -it <container> bash
1801106ade6SVladimir Kotal```
1811106ade6SVladimir Kotal
1821106ade6SVladimir KotalEnjoy.
183