├── .travis.yml ├── Dockerfile.tmpl ├── README.md ├── docker.sh ├── logging.properties ├── scripts ├── index.sh └── start.sh └── wercker.yml /.travis.yml: -------------------------------------------------------------------------------- 1 | language: bash 2 | dist: xenial 3 | services: 4 | - docker 5 | before_install: env && sudo apt-get -y update && sudo apt-get install -y curl jq 6 | script: ./docker.sh 7 | -------------------------------------------------------------------------------- /Dockerfile.tmpl: -------------------------------------------------------------------------------- 1 | FROM debian:stable-slim as fetcher 2 | 3 | RUN apt-get -y update && apt-get install -y curl 4 | # The 'OPENGROK_DOWNLOAD_LINK' will be replaced by docker.sh. 5 | RUN curl -sSL -o opengrok.tar.gz OPENGROK_DOWNLOAD_LINK 6 | 7 | FROM tomcat:9-jre8 8 | MAINTAINER OpenGrok developers "opengrok-dev@yahoogroups.com" 9 | 10 | # prepare OpenGrok binaries and directories 11 | COPY --from=fetcher opengrok.tar.gz /opengrok.tar.gz 12 | RUN mkdir -p /opengrok /var/opengrok/etc /opengrok/data /opengrok/src && \ 13 | tar -zxvf /opengrok.tar.gz -C /opengrok --strip-components 1 && \ 14 | rm -f /opengrok.tar.gz 15 | 16 | # install dependencies 17 | RUN apt-get update && apt-get install -y git subversion mercurial unzip inotify-tools python3 python3-pip && \ 18 | python3 -m pip install /opengrok/tools/opengrok-tools* 19 | # compile and install universal-ctags 20 | RUN apt-get install -y pkg-config autoconf build-essential && git clone https://github.com/universal-ctags/ctags /root/ctags && \ 21 | cd /root/ctags && ./autogen.sh && ./configure && make && make install && \ 22 | apt-get remove -y autoconf build-essential && apt-get -y autoremove && apt-get -y autoclean && \ 23 | cd /root && rm -rf /root/ctags 24 | 25 | # environment variables 26 | ENV SRC_ROOT /opengrok/src 27 | ENV DATA_ROOT /opengrok/data 28 | ENV OPENGROK_WEBAPP_CONTEXT / 29 | ENV OPENGROK_TOMCAT_BASE /usr/local/tomcat 30 | ENV CATALINA_HOME /usr/local/tomcat 31 | ENV PATH $CATALINA_HOME/bin:$PATH 32 | ENV CATALINA_BASE /usr/local/tomcat 33 | ENV CATALINA_HOME /usr/local/tomcat 34 | ENV CATALINA_TMPDIR /usr/local/tomcat/temp 35 | ENV JRE_HOME /usr 36 | ENV CLASSPATH /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar 37 | 38 | 39 | # custom deployment to / with redirect from /source 40 | RUN rm -rf /usr/local/tomcat/webapps/* && \ 41 | opengrok-deploy /opengrok/lib/source.war /usr/local/tomcat/webapps/ROOT.war && \ 42 | mkdir "/usr/local/tomcat/webapps/source" && \ 43 | echo '<% response.sendRedirect("/"); %>' > "/usr/local/tomcat/webapps/source/index.jsp" 44 | 45 | # disable all file logging 46 | ADD logging.properties /usr/local/tomcat/conf/logging.properties 47 | RUN sed -i -e 's/Valve/Disabled/' /usr/local/tomcat/conf/server.xml 48 | 49 | # add our scripts 50 | ADD scripts /scripts 51 | RUN chmod -R +x /scripts 52 | 53 | # run 54 | WORKDIR $CATALINA_HOME 55 | EXPOSE 8080 56 | CMD ["/scripts/start.sh"] 57 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | :heavy_exclamation_mark: :raising_hand_man: **NOTE: This repository is archived. It is no longer used to build official OpenGrok Docker images. These are now built from within the official OpenGrok source repository. The location of the images on Docker Hub remains the same. It is just the build process that changed. See https://github.com/oracle/opengrok/tree/master/docker for more details.** 3 | 4 | # A Docker container for OpenGrok 5 | 6 | ## OpenGrok from official source: 7 | 8 | Directly downloaded from official source: 9 | https://github.com/oracle/opengrok/releases/ 10 | 11 | You can learn more about OpenGrok at http://oracle.github.io/opengrok/ 12 | 13 | The container is available from DockerHub at https://hub.docker.com/r/opengrok/docker/ 14 | 15 | ## When not to use it 16 | 17 | This image is simple wrapper around OpenGrok environment. The indexer and the web container are **not** tuned for large workloads. If you happen to have either large source data (e.g. [AOSP](https://en.wikipedia.org/wiki/Android_Open_Source_Project) or the like) or stable service or both, it is advisable to run the service standalone. 18 | 19 | ## Additional info about the container: 20 | 21 | * Tomcat 9 22 | * JRE 8 (Required for Opengrok 1.0+) 23 | * Configurable mirroring/reindexing (default every 10 min) 24 | 25 | The mirroring step works by going through all projects and attempting to 26 | synchronize all its repositories (e.g. it will do `git pull` for Git 27 | repositories). 28 | 29 | The indexer/mirroring is set so that it does not log into files. 30 | 31 | ## How to run: 32 | 33 | The container exports ports 8080 for OpenGrok. 34 | 35 | docker run -d -v :/opengrok/src -p 8080:8080 opengrok/docker:latest 36 | 37 | The 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. 38 | 39 | By default, the index will be rebuild every ten minutes. You can adjust this 40 | time (in minutes) by passing the `REINDEX` environment variable: 41 | 42 | docker run -d -e REINDEX=30 -v :/opengrok/src -p 8080:8080 opengrok/docker:latest 43 | 44 | Setting `REINDEX` to `0` will disable automatic indexing. You can manually trigger an reindex using docker exec: 45 | 46 | docker exec /scripts/index.sh 47 | 48 | Setting `INDEXER_OPT` could pass extra options to opengrok-indexer. For example, you can run with: 49 | 50 | docker run -d -e INDEXER_OPT="-i d:vendor" -v :/opengrok/src -p 8080:8080 opengrok/docker:latest 51 | 52 | To remove all the `*/vendor/*` files from the index. You can check the indexer options on 53 | 54 | https://github.com/oracle/opengrok/wiki/Python-scripts-transition-guide 55 | 56 | To avoid the mirroring step, set the `NOMIRROR` variable to non-empty value. 57 | 58 | To display Indexer logs, use: 59 | 60 | docker logs 61 | 62 | ## OpenGrok Web-Interface 63 | 64 | The container has OpenGrok as default web app installed (accessible directly from `/`). With the above container setup, you can find it running on 65 | 66 | http://localhost:8080/ 67 | 68 | The first reindex will take some time to finish. Subsequent reindex will be incremental so will take signigicantly less time. 69 | 70 | ## Inspecting the container 71 | 72 | You can get inside a container using the [command below](https://docs.docker.com/engine/reference/commandline/exec/): 73 | 74 | ``` 75 | docker exec -it bash 76 | ``` 77 | 78 | Enjoy. 79 | -------------------------------------------------------------------------------- /docker.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # 4 | # Build and push new image to Docker hub. 5 | # 6 | # Uses the following Travis secure variables: 7 | # - DOCKER_USERNAME 8 | # - DOCKER_PASSWORD 9 | # - GITHUB_TOKEN 10 | # 11 | # These are set via https://travis-ci.com/OpenGrok/docker/settings 12 | # 13 | 14 | set -x 15 | set -e 16 | 17 | # Travis can only work on master since it needs encrypted variables. 18 | if [ "${TRAVIS_PULL_REQUEST}" != "false" ]; then 19 | exit 0 20 | fi 21 | 22 | JSON_OUT="ver.out" 23 | 24 | # 25 | # Get the latest OpenGrok version string. Use authenticated request to avoid 26 | # rate limiting induced errors. 27 | # 28 | curl -sS -o "$JSON_OUT" \ 29 | -H "Authorization: token $GITHUB_TOKEN" \ 30 | https://api.github.com/repos/oracle/opengrok/releases/latest 31 | cat "$JSON_OUT" 32 | VERSION=`jq -er .tag_name ver.out` 33 | echo "Latest OpenGrok tag: $VERSION" 34 | 35 | # Embed the tarball URL into the Dockerfile. 36 | tarball=`jq -er '.assets[]|select(.name|test("opengrok-.*tar.gz"))|.browser_download_url' "$JSON_OUT"` 37 | echo "Tarball URL: $tarball" 38 | sed "s%OPENGROK_DOWNLOAD_LINK%$tarball%" Dockerfile.tmpl > Dockerfile 39 | 40 | # Build and run the image in container. 41 | docker build -t opengrok/docker:$VERSION -t opengrok/docker:latest . 42 | docker run -d opengrok/docker 43 | docker ps -a 44 | 45 | # Publish the image to Docker hub. 46 | if [ -n "$DOCKER_PASSWORD" -a -n "$DOCKER_USERNAME" -a -n "$VERSION" ]; then 47 | echo "Pushing image for version $VERSION" 48 | echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin 49 | docker push opengrok/docker:$VERSION 50 | docker push opengrok/docker:latest 51 | fi 52 | -------------------------------------------------------------------------------- /logging.properties: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Google Inc. All Rights Reserved. 2 | # 3 | # Licensed to the Apache Software Foundation (ASF) under one or more 4 | # contributor license agreements. See the NOTICE file distributed with 5 | # this work for additional information regarding copyright ownership. 6 | # The ASF licenses this file to You under the Apache License, Version 2.0 7 | # (the "License"); you may not use this file except in compliance with 8 | # the License. You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | 18 | handlers = java.util.logging.ConsoleHandler 19 | 20 | .handlers = java.util.logging.ConsoleHandler 21 | 22 | ############################################################ 23 | # Handler specific properties. 24 | # Describes specific configuration info for Handlers. 25 | ############################################################ 26 | 27 | java.util.logging.ConsoleHandler.level = FINE 28 | java.util.logging.ConsoleHandler.formatter = org.apache.juli.OneLineFormatter 29 | 30 | ############################################################ 31 | # Facility specific properties. 32 | # Provides extra control for each logger. 33 | ############################################################ 34 | 35 | org.apache.catalina.core.ContainerBase.[Catalina].[localhost].level = INFO 36 | org.apache.catalina.core.ContainerBase.[Catalina].[localhost].handlers = java.util.logging.ConsoleHandler 37 | 38 | org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager].level = INFO 39 | org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager].handlers = java.util.logging.ConsoleHandler 40 | 41 | org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/host-manager].level = INFO 42 | org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/host-manager].handlers = java.util.logging.ConsoleHandler 43 | -------------------------------------------------------------------------------- /scripts/index.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | LOCKFILE=/var/run/opengrok-indexer 4 | URI="http://localhost:8080" 5 | 6 | if [ -f "$LOCKFILE" ]; then 7 | date +"%F %T Indexer still locked, skipping indexing" 8 | exit 1 9 | fi 10 | 11 | touch $LOCKFILE 12 | 13 | if [ -z $NOMIRROR ]; then 14 | date +"%F %T Mirroring starting" 15 | opengrok-mirror --all --uri "$URI" 16 | date +"%F %T Mirroring finished" 17 | fi 18 | 19 | date +"%F %T Indexing starting" 20 | opengrok-indexer \ 21 | -a /opengrok/lib/opengrok.jar -- \ 22 | -s /opengrok/src \ 23 | -d /opengrok/data \ 24 | -H -P -S -G \ 25 | --leadingWildCards on \ 26 | -W /var/opengrok/etc/configuration.xml \ 27 | -U "$URI" \ 28 | $INDEXER_OPT "$@" 29 | date +"%F %T Indexing finished" 30 | 31 | rm -f $LOCKFILE 32 | -------------------------------------------------------------------------------- /scripts/start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # default period for reindexing (in minutes) 4 | if [ -z "$REINDEX" ]; then 5 | REINDEX=10 6 | fi 7 | 8 | indexer(){ 9 | # Wait for Tomcat startup. 10 | date +"%F %T Waiting for Tomcat startup..." 11 | while [ "`curl --silent --write-out '%{response_code}' -o /dev/null 'http://localhost:8080/'`" == "000" ]; do 12 | sleep 1; 13 | done 14 | date +"%F %T Startup finished" 15 | 16 | if [[ ! -d /opengrok/data/index ]]; then 17 | # Populate the webapp with bare configuration. 18 | BODY_INCLUDE_FILE="/opengrok/data/body_include" 19 | if [[ -f $BODY_INCLUDE_FILE ]]; then 20 | mv "$BODY_INCLUDE_FILE" "$BODY_INCLUDE_FILE.orig" 21 | fi 22 | echo '

Waiting on the initial reindex to finish.. Stay tuned !

' > "$BODY_INCLUDE_FILE" 23 | /scripts/index.sh --noIndex 24 | rm -f "$BODY_INCLUDE_FILE" 25 | if [[ -f $BODY_INCLUDE_FILE.orig ]]; then 26 | mv "$BODY_INCLUDE_FILE.orig" "$BODY_INCLUDE_FILE" 27 | fi 28 | 29 | # Perform initial indexing. 30 | NOMIRROR=1 /scripts/index.sh 31 | date +"%F %T Initial reindex finished" 32 | fi 33 | 34 | # Continue to index every $REINDEX minutes. 35 | if [ "$REINDEX" == "0" ]; then 36 | date +"%F %T Automatic reindexing disabled" 37 | return 38 | else 39 | date +"%F %T Automatic reindexing in $REINDEX minutes..." 40 | fi 41 | while true; do 42 | sleep `expr 60 \* $REINDEX` 43 | /scripts/index.sh 44 | done 45 | } 46 | 47 | # Start all necessary services. 48 | indexer & 49 | catalina.sh run 50 | -------------------------------------------------------------------------------- /wercker.yml: -------------------------------------------------------------------------------- 1 | - internal/docker-build: 2 | dockerfile: Dockerfile 3 | image-name: opengrok 4 | --------------------------------------------------------------------------------