Skip to content

Commit ebfc1a2

Browse files
committed
HBASE-23945 Dockerfiles showing hadolint check failures
Signed-off-by: stack <stack@apache.org>
1 parent 4f76e24 commit ebfc1a2

4 files changed

Lines changed: 78 additions & 43 deletions

File tree

dev-support/Dockerfile

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,14 @@
2222
# dev-support/flaky-tests/flaky-reporting.Jenkinsfile
2323
FROM ubuntu:18.04
2424

25-
ADD . /hbase/dev-support
25+
COPY . /hbase/dev-support
2626

27-
RUN apt-get -y update \
28-
&& apt-get -y install curl python-pip \
29-
&& pip install -r /hbase/dev-support/python-requirements.txt
27+
RUN DEBIAN_FRONTEND=noninteractive apt-get -qq -y update \
28+
&& DEBIAN_FRONTEND=noninteractive apt-get -qq -y install --no-install-recommends \
29+
curl=7.58.0-2ubuntu3.8 \
30+
python2.7=2.7.17-1~18.04 \
31+
python-pip=9.0.1-2.3~ubuntu1.18.04.1 \
32+
python-setuptools=39.0.1-2 \
33+
&& apt-get clean \
34+
&& rm -rf /var/lib/apt/lists/*
35+
RUN pip install -r /hbase/dev-support/python-requirements.txt

dev-support/docker/Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,9 @@ RUN tar xzf /tmp/maven.tar.gz -C /opt && \
152152
# ensure JVMs are available under `/usr/lib/jvm` and prefix each installation
153153
# as `java-` so as to conform with Yetus's assumptions.
154154
#
155+
# when updating java or maven versions here, consider also updating
156+
# `dev-support/hbase_docker/Dockerfile` as well.
157+
#
155158

156159
# hadolint ignore=DL3010
157160
COPY --from=OPENJDK7_DOWNLOAD_IMAGE /tmp/zuluopenjdk7.tar.gz /tmp/zuluopenjdk7.tar.gz

dev-support/hbase_docker/Dockerfile

Lines changed: 60 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,37 +14,78 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616

17-
FROM ubuntu:14.04
17+
FROM ubuntu:18.04 AS BASE_IMAGE
18+
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
1819

19-
# Install Git, which is missing from the Ubuntu base images.
20-
RUN apt-get update && apt-get install -y git
20+
# hadolint ignore=DL3009
21+
RUN DEBIAN_FRONTEND=noninteractive apt-get -qq update && \
22+
DEBIAN_FRONTEND=noninteractive apt-get -qq install --no-install-recommends -y \
23+
ca-certificates=20180409 \
24+
curl=7.58.0-2ubuntu3.8 \
25+
locales=2.27-3ubuntu1
2126

22-
# Add the dependencies from the hbase_docker folder and delete ones we don't need.
23-
WORKDIR /root
24-
ADD . /root
25-
RUN find . -not -name "*tar.gz" -delete
27+
RUN locale-gen en_US.UTF-8
28+
ENV LANG=en_US.UTF-8 LANGUAGE=en_US:en LC_ALL=en_US.UTF-8
29+
30+
FROM BASE_IMAGE AS MAVEN_DOWNLOAD_IMAGE
31+
ENV MAVEN_VERSION='3.5.4'
32+
ENV MAVEN_URL "https://archive.apache.org/dist/maven/maven-3/${MAVEN_VERSION}/binaries/apache-maven-${MAVEN_VERSION}-bin.tar.gz"
33+
ENV MAVEN_SHA256 'ce50b1c91364cb77efe3776f756a6d92b76d9038b0a0782f7d53acf1e997a14d'
34+
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
35+
RUN curl --location --fail --silent --show-error --output /tmp/maven.tar.gz "${MAVEN_URL}" && \
36+
echo "${MAVEN_SHA256} */tmp/maven.tar.gz" | sha256sum -c -
37+
38+
FROM BASE_IMAGE AS OPENJDK8_DOWNLOAD_IMAGE
39+
ENV OPENJDK8_URL 'https://github.com/AdoptOpenJDK/openjdk8-binaries/releases/download/jdk8u232-b09/OpenJDK8U-jdk_x64_linux_hotspot_8u232b09.tar.gz'
40+
ENV OPENJDK8_SHA256 '7b7884f2eb2ba2d47f4c0bf3bb1a2a95b73a3a7734bd47ebf9798483a7bcc423'
41+
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
42+
RUN curl --location --fail --silent --show-error --output /tmp/adoptopenjdk8.tar.gz "${OPENJDK8_URL}" && \
43+
echo "${OPENJDK8_SHA256} */tmp/adoptopenjdk8.tar.gz" | sha256sum -c -
2644

27-
# Install Java.
28-
RUN mkdir -p /usr/java
29-
RUN tar xzf *jdk* --strip-components 1 -C /usr/java
30-
ENV JAVA_HOME /usr/java
45+
FROM BASE_IMAGE
46+
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
3147

32-
# Install Maven.
33-
RUN mkdir -p /usr/local/apache-maven
34-
RUN tar xzf *maven* --strip-components 1 -C /usr/local/apache-maven
35-
ENV MAVEN_HOME /usr/local/apache-maven
48+
RUN DEBIAN_FRONTEND=noninteractive apt-get -qq install --no-install-recommends -y \
49+
git=1:2.17.1-1ubuntu0.5 \
50+
&& \
51+
apt-get clean && \
52+
rm -rf /var/lib/apt/lists/*
3653

37-
# Add Java and Maven to the path.
38-
ENV PATH /usr/java/bin:/usr/local/apache-maven/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
54+
#
55+
# when updating java or maven versions here, consider also updating
56+
# `dev-support/docker/Dockerfile` as well.
57+
#
58+
59+
# hadolint ignore=DL3010
60+
COPY --from=MAVEN_DOWNLOAD_IMAGE /tmp/maven.tar.gz /tmp/maven.tar.gz
61+
RUN tar xzf /tmp/maven.tar.gz -C /opt && \
62+
ln -s "/opt/$(dirname "$(tar -tf /tmp/maven.tar.gz | head -n1)")" /opt/maven && \
63+
rm /tmp/maven.tar.gz
64+
65+
# hadolint ignore=DL3010
66+
COPY --from=OPENJDK8_DOWNLOAD_IMAGE /tmp/adoptopenjdk8.tar.gz /tmp/adoptopenjdk8.tar.gz
67+
RUN mkdir -p /usr/lib/jvm && \
68+
tar xzf /tmp/adoptopenjdk8.tar.gz -C /usr/lib/jvm && \
69+
ln -s "/usr/lib/jvm/$(basename "$(tar -tf /tmp/adoptopenjdk8.tar.gz | head -n1)")" /usr/lib/jvm/java-8-adoptopenjdk && \
70+
ln -s /usr/lib/jvm/java-8-adoptopenjdk /usr/lib/jvm/java-8 && \
71+
rm /tmp/adoptopenjdk8.tar.gz
72+
73+
ENV MAVEN_HOME '/opt/maven'
74+
ENV JAVA_HOME '/usr/lib/jvm/java-8'
75+
ENV PATH '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
76+
ENV PATH "${JAVA_HOME}/bin:${MAVEN_HOME}/bin:${PATH}"
3977

4078
# Pull down HBase and build it into /root/hbase-bin.
79+
WORKDIR /root
4180
RUN git clone https://gitbox.apache.org/repos/asf/hbase.git -b master
4281
RUN mvn clean install -DskipTests assembly:single -f ./hbase/pom.xml
4382
RUN mkdir -p hbase-bin
44-
RUN tar xzf /root/hbase/hbase-assembly/target/*tar.gz --strip-components 1 -C /root/hbase-bin
83+
RUN find /root/hbase/hbase-assembly/target -iname '*.tar.gz' -not -iname '*client*' \
84+
| head -n 1 \
85+
| xargs -I{} tar xzf {} --strip-components 1 -C /root/hbase-bin
4586

4687
# Set HBASE_HOME, add it to the path, and start HBase.
4788
ENV HBASE_HOME /root/hbase-bin
48-
ENV PATH /root/hbase-bin/bin:/usr/java/bin:/usr/local/apache-maven/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
89+
ENV PATH "/root/hbase-bin/bin:${PATH}"
4990

5091
CMD ["/bin/bash", "-c", "start-hbase.sh; hbase shell"]

dev-support/hbase_docker/README.md

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -29,30 +29,15 @@ and launch the HBase shell when run.
2929

3030
## Usage
3131

32-
1. Download x64 .tar.gz files of the Oracle JDK and Apache Maven and place them
33-
in this folder (i.e. both tarballs must be in the same folder as the
34-
Dockerfile). Also note that the Dockerfile will properly pick up the tarballs
35-
as long as the JDK file has "jdk" in its name and the Maven file contains
36-
"maven". As an example, while developing this Dockerfile, my working directory
37-
looked like this:
38-
39-
```
40-
$ ls -lh
41-
total 145848
42-
-rw-r--r-- 1 root root 6956162 Sep 3 15:48 apache-maven-3.2.3-bin.tar.gz
43-
-rw-r--r-- 1 root root 2072 Sep 3 15:48 Dockerfile
44-
-rw-r--r-- 1 root root 142376665 Sep 3 15:48 jdk-7u67-linux-x64.tar.gz
45-
-rw-r--r-- 1 root root 1844 Sep 3 15:56 README.md
46-
```
47-
2. Ensure that you have a recent version of Docker installed from
32+
1. Ensure that you have a recent version of Docker installed from
4833
[docker.io](http://www.docker.io).
49-
3. Set this folder as your working directory.
50-
4. Type `docker build -t hbase_docker .` to build a Docker image called **hbase_docker**.
34+
1. Set this folder as your working directory.
35+
1. Type `docker build -t hbase_docker .` to build a Docker image called **hbase_docker**.
5136
This may take 10 minutes or more the first time you run the command since it will
5237
create a Maven repository inside the image as well as checkout the master branch
5338
of HBase.
54-
5. When this completes successfully, you can run `docker run -it hbase_docker`
39+
1. When this completes successfully, you can run `docker run -it hbase_docker`
5540
to access an HBase shell running inside of a container created from the
5641
**hbase_docker** image. Alternatively, you can type `docker run -it hbase_docker
5742
bash` to start a container without a running HMaster. Within this environment,
58-
HBase is built in /root/hbase-bin.
43+
HBase is built in `/root/hbase-bin`.

0 commit comments

Comments
 (0)