Skip to content

Commit 1ca9c87

Browse files
ahornaceVladimir Kotal
authored andcommitted
Use Dockerfile linter
fixes #3683
1 parent f22e184 commit 1ca9c87

File tree

2 files changed

+30
-19
lines changed

2 files changed

+30
-19
lines changed

Dockerfile

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33

44
FROM ubuntu:bionic as build
55

6-
RUN apt-get update && apt-get install -y maven python3 python3-venv
6+
# hadolint ignore=DL3008
7+
RUN apt-get update && apt-get install --no-install-recommends -y maven python3 python3-venv && \
8+
apt-get clean && \
9+
rm -rf /var/lib/apt/lists/*
710

811
# Create a first layer to cache the "Maven World" in the local repository.
912
# Incremental docker builds will always resume after that, unless you update the pom
@@ -15,12 +18,12 @@ COPY plugins/pom.xml /mvn/plugins/
1518
COPY suggester/pom.xml /mvn/suggester/
1619

1720
# distribution and tools do not have dependencies to cache
18-
RUN sed -i 's:<module>distribution</module>::g' /mvn/pom.xml
19-
RUN sed -i 's:<module>tools</module>::g' /mvn/pom.xml
20-
21-
RUN mkdir -p /mvn/opengrok-indexer/target/jflex-sources
22-
RUN mkdir -p /mvn/opengrok-web/src/main/webapp/js
23-
RUN mkdir -p /mvn/opengrok-web/src/main/webapp/WEB-INF/ && touch /mvn/opengrok-web/src/main/webapp/WEB-INF/web.xml
21+
RUN sed -i 's:<module>distribution</module>::g' /mvn/pom.xml && \
22+
sed -i 's:<module>tools</module>::g' /mvn/pom.xml && \
23+
mkdir -p /mvn/opengrok-indexer/target/jflex-sources && \
24+
mkdir -p /mvn/opengrok-web/src/main/webapp/js && \
25+
mkdir -p /mvn/opengrok-web/src/main/webapp/WEB-INF/ && \
26+
touch /mvn/opengrok-web/src/main/webapp/WEB-INF/web.xml
2427

2528
# dummy build to cache the dependencies
2629
RUN mvn -DskipTests -Dcheckstyle.skip -Dmaven.antrun.skip package
@@ -30,33 +33,38 @@ COPY ./ /opengrok-source
3033
WORKDIR /opengrok-source
3134

3235
RUN mvn -DskipTests=true -Dmaven.javadoc.skip=true -B -V package
36+
# hadolint ignore=SC2012,DL4006
3337
RUN cp `ls -t distribution/target/*.tar.gz | head -1` /opengrok.tar.gz
3438

3539
FROM tomcat:10-jdk11
3640
LABEL maintainer="https://github.com/oracle/opengrok"
3741

3842
# install dependencies and Python tools
43+
# hadolint ignore=DL3008,DL3009
3944
RUN apt-get update && \
40-
apt-get install -y git subversion mercurial unzip inotify-tools python3 python3-pip python3-venv
45+
apt-get install --no-install-recommends -y git subversion mercurial unzip inotify-tools python3 python3-pip \
46+
python3-venv python3-setuptools
4147

4248
# compile and install universal-ctags
43-
RUN apt-get install -y pkg-config autoconf build-essential && \
49+
# hadolint ignore=DL3003,DL3008
50+
RUN apt-get install --no-install-recommends -y pkg-config automake build-essential && \
4451
git clone https://github.com/universal-ctags/ctags /root/ctags && \
4552
cd /root/ctags && ./autogen.sh && ./configure && make && make install && \
46-
apt-get remove -y autoconf build-essential && \
53+
apt-get remove -y automake build-essential && \
4754
apt-get -y autoremove && apt-get -y autoclean && \
48-
cd /root && rm -rf /root/ctags
55+
cd /root && rm -rf /root/ctags && \
56+
apt-get clean && \
57+
rm -rf /var/lib/apt/lists/*
4958

5059
# prepare OpenGrok binaries and directories
60+
# hadolint ignore=DL3010
5161
COPY --from=build opengrok.tar.gz /opengrok.tar.gz
62+
# hadolint ignore=DL3013
5263
RUN mkdir -p /opengrok /opengrok/etc /opengrok/data /opengrok/src && \
5364
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-
58-
# for /reindex REST endpoint handled by start.py
59-
RUN python3 -m pip install Flask Flask-HTTPAuth waitress
65+
rm -f /opengrok.tar.gz && \
66+
python3 -m pip install --no-cache-dir /opengrok/tools/opengrok-tools* && \
67+
python3 -m pip install --no-cache-dir Flask Flask-HTTPAuth waitress # for /reindex REST endpoint handled by start.py
6068

6169
# environment variables
6270
ENV SRC_ROOT /opengrok/src
@@ -69,11 +77,11 @@ ENV PATH $CATALINA_HOME/bin:$PATH
6977
ENV CLASSPATH /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
7078

7179
# disable all file logging
72-
ADD docker/logging.properties /usr/local/tomcat/conf/logging.properties
80+
COPY docker/logging.properties /usr/local/tomcat/conf/logging.properties
7381
RUN sed -i -e 's/Valve/Disabled/' /usr/local/tomcat/conf/server.xml
7482

7583
# add our scripts
76-
ADD docker /scripts
84+
COPY docker /scripts
7785
RUN chmod -R +x /scripts
7886

7987
# run

dev/docker.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212

1313
set -e
1414

15+
echo "Running linter"
16+
docker run --rm -i hadolint/hadolint:2.6.0 < Dockerfile || exit 1
17+
1518
API_URL="https://hub.docker.com/v2"
1619
IMAGE="opengrok/docker"
1720

0 commit comments

Comments
 (0)