|
| 1 | +# Licensed to the Apache Software Foundation (ASF) under one or more |
| 2 | +# contributor license agreements. See the NOTICE file distributed with |
| 3 | +# this work for additional information regarding copyright ownership. |
| 4 | +# The ASF licenses this file to You under the Apache License, Version 2.0 |
| 5 | +# (the "License"); you may not use this file except in compliance with |
| 6 | +# the License. You may obtain a copy of the License at |
| 7 | +# |
| 8 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +# |
| 10 | +# Unless required by applicable law or agreed to in writing, software |
| 11 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +# See the License for the specific language governing permissions and |
| 14 | +# limitations under the License. |
| 15 | +# |
| 16 | +# Standalone HBase 2.6.5 image for HugeGraph HBase backend testing. |
| 17 | +# Exposes ZooKeeper on 2181 with znode /hbase (matching hugegraph.properties defaults). |
| 18 | + |
| 19 | +FROM eclipse-temurin:11-jre-jammy |
| 20 | + |
| 21 | +ARG HBASE_VERSION=2.6.5 |
| 22 | +ARG HBASE_PRIMARY_URL=https://archive.apache.org/dist/hbase/${HBASE_VERSION}/hbase-${HBASE_VERSION}-bin.tar.gz |
| 23 | +ARG HBASE_FALLBACK_URL=https://downloads.apache.org/hbase/${HBASE_VERSION}/hbase-${HBASE_VERSION}-bin.tar.gz |
| 24 | +ARG ALLOW_UNVERIFIED_DOWNLOAD=false |
| 25 | + |
| 26 | +ENV HBASE_VERSION=${HBASE_VERSION} |
| 27 | +ENV HBASE_HOME=/opt/hbase |
| 28 | +ENV PATH=${HBASE_HOME}/bin:${PATH} |
| 29 | + |
| 30 | +RUN apt-get update && apt-get install -y --no-install-recommends \ |
| 31 | + curl \ |
| 32 | + netcat-openbsd \ |
| 33 | + && rm -rf /var/lib/apt/lists/* |
| 34 | + |
| 35 | +RUN set -eux; \ |
| 36 | + download_ok=0; \ |
| 37 | + downloaded_url=""; \ |
| 38 | + for url in "${HBASE_PRIMARY_URL}" "${HBASE_FALLBACK_URL}"; do \ |
| 39 | + [ -n "${url}" ] || continue; \ |
| 40 | + echo "Downloading HBase from ${url}"; \ |
| 41 | + if curl -fL --retry 8 --retry-delay 5 --retry-all-errors \ |
| 42 | + --connect-timeout 30 --max-time 1800 "${url}" -o /tmp/hbase.tar.gz; then \ |
| 43 | + download_ok=1; \ |
| 44 | + downloaded_url="${url}"; \ |
| 45 | + break; \ |
| 46 | + fi; \ |
| 47 | + echo "Download failed for ${url}, trying next source..."; \ |
| 48 | + rm -f /tmp/hbase.tar.gz; \ |
| 49 | + done; \ |
| 50 | + if [ "${download_ok}" -ne 1 ]; then \ |
| 51 | + echo "Unable to download HBase ${HBASE_VERSION} tarball from configured sources"; \ |
| 52 | + exit 1; \ |
| 53 | + fi; \ |
| 54 | + checksum_ok=0; \ |
| 55 | + for checksum_url in "${downloaded_url}.sha512" "${HBASE_PRIMARY_URL}.sha512" "${HBASE_FALLBACK_URL}.sha512"; do \ |
| 56 | + [ -n "${checksum_url}" ] || continue; \ |
| 57 | + if curl -fL --retry 5 --retry-delay 3 --retry-all-errors \ |
| 58 | + --connect-timeout 30 "${checksum_url}" -o /tmp/hbase.tar.gz.sha512 2>/dev/null; then \ |
| 59 | + checksum_ok=1; \ |
| 60 | + break; \ |
| 61 | + fi; \ |
| 62 | + done; \ |
| 63 | + if [ "${checksum_ok}" -eq 1 ]; then \ |
| 64 | + echo "Verifying SHA512 checksum..."; \ |
| 65 | + expected_hash=$(grep -Eio '[a-f0-9]{128}' /tmp/hbase.tar.gz.sha512 | head -n 1 | tr 'A-F' 'a-f' || true); \ |
| 66 | + if [ -z "$expected_hash" ]; then \ |
| 67 | + expected_hash=$(awk '{for (i = 1; i <= NF; i++) if (length($i) >= 8 && $i ~ /^[0-9A-Fa-f]+$/) hash = hash $i} END {if (length(hash) >= 128) print tolower(substr(hash, 1, 128))}' /tmp/hbase.tar.gz.sha512 || true); \ |
| 68 | + fi; \ |
| 69 | + if [ -n "$expected_hash" ]; then \ |
| 70 | + actual_hash=$(sha512sum /tmp/hbase.tar.gz | awk '{print $1}'); \ |
| 71 | + if [ "$expected_hash" = "$actual_hash" ]; then \ |
| 72 | + echo "SHA512 verified OK"; \ |
| 73 | + else \ |
| 74 | + echo "ERROR: SHA512 mismatch"; \ |
| 75 | + echo " Expected: $expected_hash"; \ |
| 76 | + echo " Actual: $actual_hash"; \ |
| 77 | + exit 1; \ |
| 78 | + fi; \ |
| 79 | + else \ |
| 80 | + if [ "${ALLOW_UNVERIFIED_DOWNLOAD}" = "true" ]; then \ |
| 81 | + echo "WARNING: Could not parse SHA512 file (ALLOW_UNVERIFIED_DOWNLOAD=true)"; \ |
| 82 | + else \ |
| 83 | + echo "ERROR: Could not parse SHA512 file"; \ |
| 84 | + exit 1; \ |
| 85 | + fi; \ |
| 86 | + fi; \ |
| 87 | + else \ |
| 88 | + if [ "${ALLOW_UNVERIFIED_DOWNLOAD}" = "true" ]; then \ |
| 89 | + echo "WARNING: Could not download SHA512 file (ALLOW_UNVERIFIED_DOWNLOAD=true)"; \ |
| 90 | + else \ |
| 91 | + echo "ERROR: Could not download SHA512 file"; \ |
| 92 | + exit 1; \ |
| 93 | + fi; \ |
| 94 | + fi; \ |
| 95 | + tar -xzf /tmp/hbase.tar.gz -C /opt; \ |
| 96 | + mv /opt/hbase-${HBASE_VERSION} ${HBASE_HOME}; \ |
| 97 | + rm -f /tmp/hbase.tar.gz /tmp/hbase.tar.gz.sha512 |
| 98 | + |
| 99 | +# hbase-site.xml: standalone mode, znode=/hbase (matches hugegraph.properties) |
| 100 | +COPY hbase-site.xml ${HBASE_HOME}/conf/hbase-site.xml |
| 101 | + |
| 102 | +# Entrypoint: start HBase then tail the master log |
| 103 | +COPY entrypoint.sh /entrypoint.sh |
| 104 | +RUN chmod +x /entrypoint.sh |
| 105 | + |
| 106 | +EXPOSE 2181 16000 16010 16020 16030 |
| 107 | + |
| 108 | +ENTRYPOINT ["/entrypoint.sh"] |
| 109 | + |
0 commit comments