Skip to content

Commit 944a6b3

Browse files
ahornaceVladimir Kotal
authored andcommitted
Rewrite Dockerfile to build the project (#2987)
1 parent fcbdc96 commit 944a6b3

File tree

2 files changed

+42
-17
lines changed

2 files changed

+42
-17
lines changed

.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ jobs:
8585
services:
8686
- docker
8787
before_install: dev/before_install
88-
before_script: ./mvnw -DskipTests=true -Dmaven.javadoc.skip=true -B -V package
8988
script: dev/docker.sh
9089
- stage: javadoc
9190
name: Upload javadocs to Github pages

Dockerfile

Lines changed: 42 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,60 @@
1-
FROM debian:stable-slim as fetcher
1+
# Copyright (c) 2018, 2019 Oracle and/or its affiliates. All rights reserved.
22

3-
# TODO copy just the 'distribution' directory, not all source code
3+
FROM ubuntu:bionic as build
4+
5+
RUN apt-get update && apt-get install -y openjdk-8-jdk maven python3 python3-venv
6+
7+
# Create a first layer to cache the "Maven World" in the local repository.
8+
# Incremental docker builds will always resume after that, unless you update the pom
9+
WORKDIR /mvn
10+
COPY pom.xml /mvn/
11+
COPY opengrok-indexer/pom.xml /mvn/opengrok-indexer/
12+
COPY opengrok-web/pom.xml /mvn/opengrok-web/
13+
COPY plugins/pom.xml /mvn/plugins/
14+
COPY suggester/pom.xml /mvn/suggester/
15+
16+
# distribution and opengrok-tools do not have dependencies to cache
17+
RUN sed -i 's:<module>distribution</module>::g' /mvn/pom.xml
18+
RUN sed -i 's:<module>opengrok-tools</module>::g' /mvn/pom.xml
19+
20+
RUN mkdir -p /mvn/opengrok-indexer/target/jflex-sources
21+
RUN mkdir -p /mvn/opengrok-web/src/main/webapp
22+
COPY opengrok-indexer/jflex-tt.txt /mvn/opengrok-indexer/jflex-tt.txt
23+
COPY opengrok-indexer/jflex-tt-end.txt /mvn/opengrok-indexer/jflex-tt-end.txt
24+
COPY opengrok-indexer/jflex-code.txt /mvn/opengrok-indexer/jflex-code.txt
25+
COPY opengrok-indexer/jflex-code-end.txt /mvn/opengrok-indexer/jflex-code-end.txt
26+
RUN mkdir -p /mvn/opengrok-web/src/main/webapp/WEB-INF/ && touch /mvn/opengrok-web/src/main/webapp/WEB-INF/web.xml
27+
28+
# dummy build to cache the dependencies
29+
RUN mvn -DskipTests -Dcheckstyle.skip -Dmaven.antrun.skip package
30+
31+
# build the project
432
COPY ./ /opengrok-source
533
WORKDIR /opengrok-source
634

7-
# update the system
8-
RUN apt-get update
9-
10-
# find most recent package file
11-
RUN cp `ls -t distribution/target/*.tar.gz | head -n1 |awk '{printf("%s",$0)}'` /opengrok.tar.gz
35+
RUN mvn -DskipTests=true -Dmaven.javadoc.skip=true -B -V package
36+
RUN cp distribution/target/*.tar.gz /opengrok.tar.gz
1237

1338
FROM tomcat:9-jre8
14-
LABEL maintainer "[email protected]"
15-
16-
# prepare OpenGrok binaries and directories
17-
COPY --from=fetcher opengrok.tar.gz /opengrok.tar.gz
18-
RUN mkdir -p /opengrok /opengrok/etc /opengrok/data /opengrok/src && \
19-
tar -zxvf /opengrok.tar.gz -C /opengrok --strip-components 1 && \
20-
rm -f /opengrok.tar.gz
39+
LABEL maintainer="[email protected]"
2140

2241
# install dependencies and Python tools
23-
RUN apt-get update && apt-get install -y git subversion mercurial unzip inotify-tools python3 python3-pip python3-venv && \
24-
python3 -m pip install /opengrok/tools/opengrok-tools*
42+
RUN apt-get update && apt-get install -y git subversion mercurial unzip inotify-tools python3 python3-pip python3-venv
2543

2644
# compile and install universal-ctags
2745
RUN apt-get install -y pkg-config autoconf build-essential && git clone https://github.com/universal-ctags/ctags /root/ctags && \
2846
cd /root/ctags && ./autogen.sh && ./configure && make && make install && \
2947
apt-get remove -y autoconf build-essential && apt-get -y autoremove && apt-get -y autoclean && \
3048
cd /root && rm -rf /root/ctags
3149

50+
# prepare OpenGrok binaries and directories
51+
COPY --from=build opengrok.tar.gz /opengrok.tar.gz
52+
RUN mkdir -p /opengrok /opengrok/etc /opengrok/data /opengrok/src && \
53+
tar -zxvf /opengrok.tar.gz -C /opengrok --strip-components 1 && \
54+
rm -f /opengrok.tar.gz
55+
56+
RUN python3 -m pip install /opengrok/tools/opengrok-tools*
57+
3258
# environment variables
3359
ENV SRC_ROOT /opengrok/src
3460
ENV DATA_ROOT /opengrok/data

0 commit comments

Comments
 (0)