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 RUN DEBIAN_FRONTEND=noninteractive apt-get -qq update && \
28 DEBIAN_FRONTEND=noninteractive apt-get -qq install --no-install-recommends -y \
29 ca-certificates=20180409 \
33 # install dependencies from system packages.
34 # be careful not to install any system packages (i.e., findbugs) that will
35 # pull in the default-jre.
37 # bring the base image into conformance with the expectations imposed by
38 # Yetus and our personality file of what a build environment looks like.
40 build-essential=12.4ubuntu1 \
46 # install the dependencies required in order to enable the sundry precommit
47 # checks/features provided by Yetus plugins.
49 libperl-critic-perl='1.130-*' \
51 python3-pip='9.0.1-*' \
52 python3-setuptools='39.0.1-*' \
55 shellcheck='0.4.6-*' \
58 rm -rf /var/lib/apt/lists/*
60 RUN python3 -mpip install --upgrade pip && \
61 python3 -mpip install pylint==2.4.4
63 RUN gem install --no-document \
68 RUN locale-gen en_US.UTF-8
69 ENV LANG=en_US.UTF-8 LANGUAGE=en_US:en LC_ALL=en_US.UTF-8
72 # download sundry dependencies
75 FROM BASE_IMAGE AS SPOTBUGS_DOWNLOAD_IMAGE
76 ENV SPOTBUGS_VERSION '4.2.2'
77 ENV SPOTBUGS_URL "https://repo.maven.apache.org/maven2/com/github/spotbugs/spotbugs/${SPOTBUGS_VERSION}/spotbugs-${SPOTBUGS_VERSION}.tgz"
78 ENV SPOTBUGS_SHA256 '4967c72396e34b86b9458d0c34c5ed185770a009d357df8e63951ee2844f769f'
79 SHELL ["/bin/bash", "-o", "pipefail", "-c"]
80 RUN curl --location --fail --silent --show-error --output /tmp/spotbugs.tgz "${SPOTBUGS_URL}" && \
81 echo "${SPOTBUGS_SHA256} */tmp/spotbugs.tgz" | sha256sum -c -
83 FROM BASE_IMAGE AS HADOLINT_DOWNLOAD_IMAGE
84 ENV HADOLINT_VERSION '1.17.5'
85 ENV HADOLINT_URL "https://github.com/hadolint/hadolint/releases/download/v${HADOLINT_VERSION}/hadolint-Linux-x86_64"
86 ENV HADOLINT_SHA256 '20dd38bc0602040f19268adc14c3d1aae11af27b463af43f3122076baf827a35'
87 SHELL ["/bin/bash", "-o", "pipefail", "-c"]
88 RUN curl --location --fail --silent --show-error --output /tmp/hadolint "${HADOLINT_URL}" && \
89 echo "${HADOLINT_SHA256} */tmp/hadolint" | sha256sum -c -
91 FROM BASE_IMAGE AS MAVEN_DOWNLOAD_IMAGE
92 ENV MAVEN_VERSION='3.6.3'
93 ENV MAVEN_URL "https://archive.apache.org/dist/maven/maven-3/${MAVEN_VERSION}/binaries/apache-maven-${MAVEN_VERSION}-bin.tar.gz"
94 ENV MAVEN_SHA512 'c35a1803a6e70a126e80b2b3ae33eed961f83ed74d18fcd16909b2d44d7dada3203f1ffe726c17ef8dcca2dcaa9fca676987befeadc9b9f759967a8cb77181c0'
95 SHELL ["/bin/bash", "-o", "pipefail", "-c"]
96 RUN curl --location --fail --silent --show-error --output /tmp/maven.tar.gz "${MAVEN_URL}" && \
97 echo "${MAVEN_SHA512} */tmp/maven.tar.gz" | sha512sum -c -
99 FROM BASE_IMAGE AS OPENJDK7_DOWNLOAD_IMAGE
100 ENV OPENJDK7_URL 'https://cdn.azul.com/zulu/bin/zulu7.36.0.5-ca-jdk7.0.252-linux_x64.tar.gz'
101 ENV OPENJDK7_SHA256 'e0f34c242e6d456dac3e2c8a9eaeacfa8ea75c4dfc3e8818190bf0326e839d82'
102 SHELL ["/bin/bash", "-o", "pipefail", "-c"]
103 RUN curl --location --fail --silent --show-error --output /tmp/zuluopenjdk7.tar.gz "${OPENJDK7_URL}" && \
104 echo "${OPENJDK7_SHA256} */tmp/zuluopenjdk7.tar.gz" | sha256sum -c -
106 FROM BASE_IMAGE AS OPENJDK8_DOWNLOAD_IMAGE
107 ENV OPENJDK8_URL 'https://github.com/AdoptOpenJDK/openjdk8-binaries/releases/download/jdk8u282-b08/OpenJDK8U-jdk_x64_linux_hotspot_8u282b08.tar.gz'
108 ENV OPENJDK8_SHA256 'e6e6e0356649b9696fa5082cfcb0663d4bef159fc22d406e3a012e71fce83a5c'
109 SHELL ["/bin/bash", "-o", "pipefail", "-c"]
110 RUN curl --location --fail --silent --show-error --output /tmp/adoptopenjdk8.tar.gz "${OPENJDK8_URL}" && \
111 echo "${OPENJDK8_SHA256} */tmp/adoptopenjdk8.tar.gz" | sha256sum -c -
113 FROM BASE_IMAGE AS OPENJDK11_DOWNLOAD_IMAGE
114 ENV OPENJDK11_URL 'https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.10%2B9/OpenJDK11U-jdk_x64_linux_hotspot_11.0.10_9.tar.gz'
115 ENV OPENJDK11_SHA256 'ae78aa45f84642545c01e8ef786dfd700d2226f8b12881c844d6a1f71789cb99'
116 SHELL ["/bin/bash", "-o", "pipefail", "-c"]
117 RUN curl --location --fail --silent --show-error --output /tmp/adoptopenjdk11.tar.gz "${OPENJDK11_URL}" && \
118 echo "${OPENJDK11_SHA256} */tmp/adoptopenjdk11.tar.gz" | sha256sum -c -
121 # build the final image
125 SHELL ["/bin/bash", "-o", "pipefail", "-c"]
127 # hadolint ignore=DL3010
128 COPY --from=SPOTBUGS_DOWNLOAD_IMAGE /tmp/spotbugs.tgz /tmp/spotbugs.tgz
129 RUN tar xzf /tmp/spotbugs.tgz -C /opt && \
130 ln -s "/opt/$(tar -tf /tmp/spotbugs.tgz | head -n1 | cut -d/ -f1)" /opt/spotbugs && \
131 chmod -R a+x /opt/spotbugs/bin/* && \
134 COPY --from=HADOLINT_DOWNLOAD_IMAGE /tmp/hadolint /tmp/hadolint
135 RUN mv /tmp/hadolint /usr/local/bin && \
136 chmod a+x /usr/local/bin/hadolint
138 # hadolint ignore=DL3010
139 COPY --from=MAVEN_DOWNLOAD_IMAGE /tmp/maven.tar.gz /tmp/maven.tar.gz
140 RUN tar xzf /tmp/maven.tar.gz -C /opt && \
141 ln -s "/opt/$(dirname "$(tar -tf /tmp/maven.tar.gz | head -n1)")" /opt/maven && \
145 # ensure JVMs are available under `/usr/lib/jvm` and prefix each installation
146 # as `java-` so as to conform with Yetus's assumptions.
148 # when updating java or maven versions here, consider also updating
149 # `dev-support/hbase_docker/Dockerfile` as well.
152 # hadolint ignore=DL3010
153 COPY --from=OPENJDK7_DOWNLOAD_IMAGE /tmp/zuluopenjdk7.tar.gz /tmp/zuluopenjdk7.tar.gz
154 RUN mkdir -p /usr/lib/jvm && \
155 tar xzf /tmp/zuluopenjdk7.tar.gz -C /usr/lib/jvm && \
156 ln -s "/usr/lib/jvm/$(basename "$(tar -tf /tmp/zuluopenjdk7.tar.gz | head -n1)")" /usr/lib/jvm/java-7-zuluopenjdk && \
157 ln -s /usr/lib/jvm/java-7-zuluopenjdk /usr/lib/jvm/java-7 && \
158 rm /tmp/zuluopenjdk7.tar.gz
160 # hadolint ignore=DL3010
161 COPY --from=OPENJDK8_DOWNLOAD_IMAGE /tmp/adoptopenjdk8.tar.gz /tmp/adoptopenjdk8.tar.gz
162 RUN mkdir -p /usr/lib/jvm && \
163 tar xzf /tmp/adoptopenjdk8.tar.gz -C /usr/lib/jvm && \
164 ln -s "/usr/lib/jvm/$(basename "$(tar -tf /tmp/adoptopenjdk8.tar.gz | head -n1)")" /usr/lib/jvm/java-8-adoptopenjdk && \
165 ln -s /usr/lib/jvm/java-8-adoptopenjdk /usr/lib/jvm/java-8 && \
166 rm /tmp/adoptopenjdk8.tar.gz
168 # hadolint ignore=DL3010
169 COPY --from=OPENJDK11_DOWNLOAD_IMAGE /tmp/adoptopenjdk11.tar.gz /tmp/adoptopenjdk11.tar.gz
170 RUN mkdir -p /usr/lib/jvm && \
171 tar xzf /tmp/adoptopenjdk11.tar.gz -C /usr/lib/jvm && \
172 ln -s "/usr/lib/jvm/$(basename "$(tar -tf /tmp/adoptopenjdk11.tar.gz | head -n1)")" /usr/lib/jvm/java-11-adoptopenjdk && \
173 ln -s /usr/lib/jvm/java-11-adoptopenjdk /usr/lib/jvm/java-11 && \
174 rm /tmp/adoptopenjdk11.tar.gz
176 # configure default environment for Yetus. Yetus in dockermode seems to require
177 # these values to be specified here; the various --foo-path flags do not
178 # propigate as expected, while these are honored.
179 # TODO (nd): is this really true? investigate and file a ticket.
180 ENV SPOTBUGS_HOME '/opt/spotbugs'
181 ENV MAVEN_HOME '/opt/maven'
182 ENV MAVEN_OPTS '-Xmx3.6G'
187 # Everything past this point is either not needed for testing or breaks Yetus.
188 # So tell Yetus not to read the rest of the file: