Skip to content

Commit f8f8555

Browse files
committed
HBASE-27915 Update hbase_docker with an extra Dockerfile compatible with mac m1 platform (#5286)
Signed-off-by: Tak Lon (Stephen) Wu <[email protected]> (cherry picked from commit e5b5816)
1 parent f5d7882 commit f8f8555

File tree

2 files changed

+95
-0
lines changed

2 files changed

+95
-0
lines changed

dev-support/hbase_docker/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,6 @@ this image will start the HMaster and launch the HBase shell when run.
4141
**hbase_docker** image. Alternatively, you can type `docker run -it hbase_docker
4242
bash` to start a container without a running HMaster. Within this environment,
4343
HBase is built in `/root/hbase-bin`.
44+
45+
> NOTE: When running on mac m1 platforms, the docker file requires setting platfrom flag explicitly.
46+
> You may use same instructions above running from to the "./m1" sub-dir.
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
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
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
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.
16+
17+
FROM --platform=linux/amd64 ubuntu:22.04 AS base_image
18+
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
19+
20+
RUN DEBIAN_FRONTEND=noninteractive apt-get -qq update && \
21+
DEBIAN_FRONTEND=noninteractive apt-get -qq install --no-install-recommends -y \
22+
ca-certificates=20211016 \
23+
curl='7.81.0-*' \
24+
git='1:2.34.1-*' \
25+
locales='2.35-*' \
26+
&& \
27+
apt-get clean && \
28+
rm -rf /var/lib/apt/lists/* \
29+
&& \
30+
locale-gen en_US.UTF-8
31+
ENV LANG=en_US.UTF-8 LANGUAGE=en_US:en LC_ALL=en_US.UTF-8
32+
33+
FROM base_image AS maven_download_image
34+
ENV MAVEN_VERSION='3.8.6'
35+
ENV MAVEN_URL "https://archive.apache.org/dist/maven/maven-3/${MAVEN_VERSION}/binaries/apache-maven-${MAVEN_VERSION}-bin.tar.gz"
36+
ENV MAVEN_SHA512 'f790857f3b1f90ae8d16281f902c689e4f136ebe584aba45e4b1fa66c80cba826d3e0e52fdd04ed44b4c66f6d3fe3584a057c26dfcac544a60b301e6d0f91c26'
37+
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
38+
RUN curl --location --fail --silent --show-error --output /tmp/maven.tar.gz "${MAVEN_URL}" && \
39+
echo "${MAVEN_SHA512} */tmp/maven.tar.gz" | sha512sum -c -
40+
41+
FROM base_image AS openjdk8_download_image
42+
ENV OPENJDK8_URL 'https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u352-b08/OpenJDK8U-jdk_x64_linux_hotspot_8u352b08.tar.gz'
43+
ENV OPENJDK8_SHA256 '1633bd7590cb1cd72f5a1378ae8294451028b274d798e2a4ac672059a2f00fee'
44+
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
45+
RUN curl --location --fail --silent --show-error --output /tmp/adoptopenjdk8.tar.gz "${OPENJDK8_URL}" && \
46+
echo "${OPENJDK8_SHA256} */tmp/adoptopenjdk8.tar.gz" | sha256sum -c -
47+
48+
FROM base_image
49+
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
50+
51+
#
52+
# when updating java or maven versions here, consider also updating
53+
# `dev-support/docker/Dockerfile` as well.
54+
#
55+
56+
# hadolint ignore=DL3010
57+
COPY --from=maven_download_image /tmp/maven.tar.gz /tmp/maven.tar.gz
58+
RUN tar xzf /tmp/maven.tar.gz -C /opt && \
59+
ln -s "/opt/$(dirname "$(tar -tf /tmp/maven.tar.gz | head -n1)")" /opt/maven && \
60+
rm /tmp/maven.tar.gz
61+
62+
# hadolint ignore=DL3010
63+
COPY --from=openjdk8_download_image /tmp/adoptopenjdk8.tar.gz /tmp/adoptopenjdk8.tar.gz
64+
RUN mkdir -p /usr/lib/jvm && \
65+
tar xzf /tmp/adoptopenjdk8.tar.gz -C /usr/lib/jvm && \
66+
ln -s "/usr/lib/jvm/$(basename "$(tar -tf /tmp/adoptopenjdk8.tar.gz | head -n1)")" /usr/lib/jvm/java-8-adoptopenjdk && \
67+
ln -s /usr/lib/jvm/java-8-adoptopenjdk /usr/lib/jvm/java-8 && \
68+
rm /tmp/adoptopenjdk8.tar.gz
69+
70+
ENV MAVEN_HOME '/opt/maven'
71+
ENV JAVA_HOME '/usr/lib/jvm/java-8'
72+
ENV PATH '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
73+
ENV PATH "${JAVA_HOME}/bin:${MAVEN_HOME}/bin:${PATH}"
74+
75+
# Pull down HBase and build it into /root/hbase-bin.
76+
WORKDIR /root
77+
ARG BRANCH_OR_TAG=master
78+
RUN git clone --depth 1 -b ${BRANCH_OR_TAG} https://github.com/apache/hbase.git \
79+
&& \
80+
mvn -T1C clean install -DskipTests assembly:single -f ./hbase/pom.xml \
81+
&& \
82+
mkdir -p hbase-bin \
83+
&& \
84+
find /root/hbase/hbase-assembly/target -iname '*.tar.gz' -not -iname '*client*' \
85+
| head -n 1 \
86+
| xargs -I{} tar xzf {} --strip-components 1 -C /root/hbase-bin
87+
88+
# Set HBASE_HOME, add it to the path, and start HBase.
89+
ENV HBASE_HOME /root/hbase-bin
90+
ENV PATH "/root/hbase-bin/bin:${PATH}"
91+
92+
CMD ["/bin/bash", "-c", "start-hbase.sh; hbase shell"]

0 commit comments

Comments
 (0)