HBASE-23945 Dockerfiles showing hadolint check failures
[hbase.git] / dev-support / docker / Dockerfile
blob3c1423d386cb26b0533a2f1f9fa760728f5b0b17
1 # Licensed to the Apache Software Foundation (ASF) under one
2 # or more contributor license agreements.  See the NOTICE file
3 # distributed with this work for additional information
4 # regarding copyright ownership.  The ASF licenses this file
5 # to you under the Apache License, Version 2.0 (the
6 # "License"); you may not use this file except in compliance
7 # with the License.  You may obtain a copy of the License at
9 #     http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
18 # Dockerfile used as the build and test environment, amenable to Yetus.
20 # Built in multiple stages so as to avoid re-downloading large binaries when
21 # tweaking unrelated aspects of the image.
23 # start with a minimal image into which we can download remote tarballs
24 FROM ubuntu:18.04 AS BASE_IMAGE
25 SHELL ["/bin/bash", "-o", "pipefail", "-c"]
27 # hadolint ignore=DL3009
28 RUN DEBIAN_FRONTEND=noninteractive apt-get -qq update && \
29   DEBIAN_FRONTEND=noninteractive apt-get -qq install --no-install-recommends -y \
30     ca-certificates=20180409 \
31     curl=7.58.0-2ubuntu3.8 \
32     locales=2.27-3ubuntu1
34 RUN locale-gen en_US.UTF-8
35 ENV LANG=en_US.UTF-8 LANGUAGE=en_US:en LC_ALL=en_US.UTF-8
38 # download sundry dependencies
41 FROM BASE_IMAGE AS FINDBUGS_DOWNLOAD_IMAGE
42 # TODO: replace with Spotbugs HBASE-23077, HBASE-22383
43 ENV FINDBUGS_VERSION '3.0.1'
44 ENV FINDBUGS_URL "https://downloads.sourceforge.net/project/findbugs/findbugs/${FINDBUGS_VERSION}/findbugs-${FINDBUGS_VERSION}.tar.gz"
45 ENV FINDBUGS_SHA256 'e80e0da0c213a27504ef3188ef25f107651700ffc66433eac6a7454bbe336419'
46 SHELL ["/bin/bash", "-o", "pipefail", "-c"]
47 RUN curl --location --fail --silent --show-error --output /tmp/findbugs.tar.gz "${FINDBUGS_URL}" && \
48   echo "${FINDBUGS_SHA256} */tmp/findbugs.tar.gz" | sha256sum -c -
50 FROM BASE_IMAGE AS HADOLINT_DOWNLOAD_IMAGE
51 ENV HADOLINT_VERSION '1.17.5'
52 ENV HADOLINT_URL "https://github.com/hadolint/hadolint/releases/download/v${HADOLINT_VERSION}/hadolint-Linux-x86_64"
53 ENV HADOLINT_SHA256 '20dd38bc0602040f19268adc14c3d1aae11af27b463af43f3122076baf827a35'
54 SHELL ["/bin/bash", "-o", "pipefail", "-c"]
55 RUN curl --location --fail --silent --show-error --output /tmp/hadolint "${HADOLINT_URL}" && \
56   echo "${HADOLINT_SHA256} */tmp/hadolint" | sha256sum -c -
58 FROM BASE_IMAGE AS MAVEN_DOWNLOAD_IMAGE
59 ENV MAVEN_VERSION='3.5.4'
60 ENV MAVEN_URL "https://archive.apache.org/dist/maven/maven-3/${MAVEN_VERSION}/binaries/apache-maven-${MAVEN_VERSION}-bin.tar.gz"
61 ENV MAVEN_SHA256 'ce50b1c91364cb77efe3776f756a6d92b76d9038b0a0782f7d53acf1e997a14d'
62 SHELL ["/bin/bash", "-o", "pipefail", "-c"]
63 RUN curl --location --fail --silent --show-error --output /tmp/maven.tar.gz "${MAVEN_URL}" && \
64   echo "${MAVEN_SHA256} */tmp/maven.tar.gz" | sha256sum -c -
66 FROM BASE_IMAGE AS OPENJDK7_DOWNLOAD_IMAGE
67 ENV OPENJDK7_URL 'https://cdn.azul.com/zulu/bin/zulu7.36.0.5-ca-jdk7.0.252-linux_x64.tar.gz'
68 ENV OPENJDK7_SHA256 'e0f34c242e6d456dac3e2c8a9eaeacfa8ea75c4dfc3e8818190bf0326e839d82'
69 SHELL ["/bin/bash", "-o", "pipefail", "-c"]
70 RUN curl --location --fail --silent --show-error --output /tmp/zuluopenjdk7.tar.gz "${OPENJDK7_URL}" && \
71   echo "${OPENJDK7_SHA256} */tmp/zuluopenjdk7.tar.gz" | sha256sum -c -
73 FROM BASE_IMAGE AS OPENJDK8_DOWNLOAD_IMAGE
74 ENV OPENJDK8_URL 'https://github.com/AdoptOpenJDK/openjdk8-binaries/releases/download/jdk8u232-b09/OpenJDK8U-jdk_x64_linux_hotspot_8u232b09.tar.gz'
75 ENV OPENJDK8_SHA256 '7b7884f2eb2ba2d47f4c0bf3bb1a2a95b73a3a7734bd47ebf9798483a7bcc423'
76 SHELL ["/bin/bash", "-o", "pipefail", "-c"]
77 RUN curl --location --fail --silent --show-error --output /tmp/adoptopenjdk8.tar.gz "${OPENJDK8_URL}" && \
78   echo "${OPENJDK8_SHA256} */tmp/adoptopenjdk8.tar.gz" | sha256sum -c -
80 FROM BASE_IMAGE AS OPENJDK11_DOWNLOAD_IMAGE
81 ENV OPENJDK11_URL 'https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.6%2B10/OpenJDK11U-jdk_x64_linux_hotspot_11.0.6_10.tar.gz'
82 ENV OPENJDK11_SHA256 '330d19a2eaa07ed02757d7a785a77bab49f5ee710ea03b4ee2fa220ddd0feffc'
83 SHELL ["/bin/bash", "-o", "pipefail", "-c"]
84 RUN curl --location --fail --silent --show-error --output /tmp/adoptopenjdk11.tar.gz "${OPENJDK11_URL}" && \
85   echo "${OPENJDK11_SHA256} */tmp/adoptopenjdk11.tar.gz" | sha256sum -c -
88 # build the final image
91 FROM BASE_IMAGE
92 SHELL ["/bin/bash", "-o", "pipefail", "-c"]
95 # install dependencies from system packages.
96 # be careful not to install any system packages (i.e., findbugs) that will
97 # pull in the default-jre.
100 # bring the base image into conformance with the expectations imposed by
101 # Yetus and our personality file of what a build environment looks like.
102 RUN DEBIAN_FRONTEND=noninteractive apt-get -qq install --no-install-recommends -y \
103   bash=4.4.18-2ubuntu1.2 \
104   build-essential=12.4ubuntu1 \
105   curl=7.58.0-2ubuntu3.8 \
106   diffutils=1:3.6-1 \
107   git=1:2.17.1-1ubuntu0.5 \
108   rsync=3.1.2-2.1ubuntu1 \
109   tar=1.29b-2ubuntu0.1 \
110   wget=1.19.4-1ubuntu2.2
112 # install the dependencies required in order to enable the sundry precommit
113 # checks/features provided by Yetus plugins.
114 RUN DEBIAN_FRONTEND=noninteractive apt-get -qq install --no-install-recommends -y \
115   bats=0.4.0-1.1 \
116   libperl-critic-perl=1.130-1 \
117   python3=3.6.7-1~18.04 \
118   python3-pip=9.0.1-2.3~ubuntu1.18.04.1 \
119   python3-setuptools=39.0.1-2 \
120   ruby=1:2.5.1 \
121   ruby-dev=1:2.5.1 \
122   shellcheck=0.4.6-1 \
123   && \
124   apt-get clean && \
125   rm -rf /var/lib/apt/lists/*
127 RUN python3 -mpip install --upgrade pip && \
128   python3 -mpip install pylint==2.4.4
130 RUN gem install --no-document \
131   rake:13.0.1 \
132   rubocop:0.80.0 \
133   ruby-lint:2.3.1
135 # hadolint ignore=DL3010
136 COPY --from=FINDBUGS_DOWNLOAD_IMAGE /tmp/findbugs.tar.gz /tmp/findbugs.tar.gz
137 RUN tar xzf /tmp/findbugs.tar.gz -C /opt && \
138   ln -s "/opt/$(dirname "$(tar -tf /tmp/findbugs.tar.gz | head -n1)")" /opt/findbugs && \
139   rm /tmp/findbugs.tar.gz
141 COPY --from=HADOLINT_DOWNLOAD_IMAGE /tmp/hadolint /tmp/hadolint
142 RUN mv /tmp/hadolint /usr/local/bin && \
143   chmod a+x /usr/local/bin/hadolint
145 # hadolint ignore=DL3010
146 COPY --from=MAVEN_DOWNLOAD_IMAGE /tmp/maven.tar.gz /tmp/maven.tar.gz
147 RUN tar xzf /tmp/maven.tar.gz -C /opt && \
148   ln -s "/opt/$(dirname "$(tar -tf /tmp/maven.tar.gz | head -n1)")" /opt/maven && \
149   rm /tmp/maven.tar.gz
152 # ensure JVMs are available under `/usr/lib/jvm` and prefix each installation
153 # as `java-` so as to conform with Yetus's assumptions.
155 # when updating java or maven versions here, consider also updating
156 # `dev-support/hbase_docker/Dockerfile` as well.
159 # hadolint ignore=DL3010
160 COPY --from=OPENJDK7_DOWNLOAD_IMAGE /tmp/zuluopenjdk7.tar.gz /tmp/zuluopenjdk7.tar.gz
161 RUN mkdir -p /usr/lib/jvm && \
162   tar xzf /tmp/zuluopenjdk7.tar.gz -C /usr/lib/jvm && \
163   ln -s "/usr/lib/jvm/$(basename "$(tar -tf /tmp/zuluopenjdk7.tar.gz | head -n1)")" /usr/lib/jvm/java-7-zuluopenjdk && \
164   ln -s /usr/lib/jvm/java-7-zuluopenjdk /usr/lib/jvm/java-7 && \
165   rm /tmp/zuluopenjdk7.tar.gz
167 # hadolint ignore=DL3010
168 COPY --from=OPENJDK8_DOWNLOAD_IMAGE /tmp/adoptopenjdk8.tar.gz /tmp/adoptopenjdk8.tar.gz
169 RUN mkdir -p /usr/lib/jvm && \
170   tar xzf /tmp/adoptopenjdk8.tar.gz -C /usr/lib/jvm && \
171   ln -s "/usr/lib/jvm/$(basename "$(tar -tf /tmp/adoptopenjdk8.tar.gz | head -n1)")" /usr/lib/jvm/java-8-adoptopenjdk && \
172   ln -s /usr/lib/jvm/java-8-adoptopenjdk /usr/lib/jvm/java-8 && \
173   rm /tmp/adoptopenjdk8.tar.gz
175 # hadolint ignore=DL3010
176 COPY --from=OPENJDK11_DOWNLOAD_IMAGE /tmp/adoptopenjdk11.tar.gz /tmp/adoptopenjdk11.tar.gz
177 RUN mkdir -p /usr/lib/jvm && \
178   tar xzf /tmp/adoptopenjdk11.tar.gz -C /usr/lib/jvm && \
179   ln -s "/usr/lib/jvm/$(basename "$(tar -tf /tmp/adoptopenjdk11.tar.gz | head -n1)")" /usr/lib/jvm/java-11-adoptopenjdk && \
180   ln -s /usr/lib/jvm/java-11-adoptopenjdk /usr/lib/jvm/java-11 && \
181   rm /tmp/adoptopenjdk11.tar.gz
183 # configure default environment for Yetus. Yetus in dockermode seems to require
184 # these values to be specified here; the various --foo-path flags do not
185 # propigate as expected, while these are honored.
186 # TODO (nd): is this really true? investigate and file a ticket.
187 ENV FINDBUGS_HOME '/opt/findbugs'
188 ENV MAVEN_HOME '/opt/maven'
189 ENV MAVEN_OPTS '-Xms6G -Xmx6G'
191 CMD ["/bin/bash"]
194 # Everything past this point is either not needed for testing or breaks Yetus.
195 # So tell Yetus not to read the rest of the file:
196 # YETUS CUT HERE