From 2b0ce69ad1bbb3ec6d9b00da29bf8df30cb92923 Mon Sep 17 00:00:00 2001 From: mbarison Date: Fri, 19 Jan 2018 10:08:31 -0500 Subject: [PATCH 1/2] * Changed version 1.2.6 * Use dispatcher to get closest mirror site * Base on openjdk:8-jre-alpine image * GPG download authentication --- Dockerfile | 6 +++--- cleanup-hbase.sh | 9 +-------- config-hbase.sh | 20 +++++++++++++++----- prepare-hbase.sh | 28 +++++++++++++++++++++++----- 4 files changed, 42 insertions(+), 21 deletions(-) diff --git a/Dockerfile b/Dockerfile index 18aa7a9..182e1d0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,15 +1,15 @@ # HBase in Docker # -# Version 0.3 +# Version 0.4 # http://docs.docker.io/en/latest/use/builder/ -FROM ubuntu:xenial +FROM openjdk:8-jre-alpine MAINTAINER Dave Beckett COPY *.sh /build/ -ENV HBASE_VERSION 1.2.4 +ENV HBASE_VERSION 1.2.6 RUN /build/prepare-hbase.sh && \ cd /opt/hbase && /build/build-hbase.sh \ diff --git a/cleanup-hbase.sh b/cleanup-hbase.sh index 4f480d9..2f00769 100755 --- a/cleanup-hbase.sh +++ b/cleanup-hbase.sh @@ -2,15 +2,8 @@ . /build/config-hbase.sh -AUTO_ADDED_PACKAGES=`apt-mark showauto` +apk del $HBASE_BUILD_PACKAGES -apt-get remove --purge -y $HBASE_BUILD_PACKAGES $AUTO_ADDED_PACKAGES - -# Install the run-time dependencies -apt-get install $minimal_apt_get_args $HBASE_RUN_PACKAGES - -# . /build/cleanup.sh rm -rf /tmp/* /var/tmp/* -apt-get clean rm -rf /var/lib/apt/lists/* diff --git a/config-hbase.sh b/config-hbase.sh index 76c0ce7..00a90a5 100755 --- a/config-hbase.sh +++ b/config-hbase.sh @@ -2,23 +2,33 @@ # . /build/config.sh +function get_closest_site() { + +DISPATCHER_SITE="http://www.apache.org/dyn/closer.cgi/hbase/" + +echo $(curl -s $DISPATCHER_SITE | grep strong | head -n 1 | sed 's|.*href="\(.\+\?\)".*|\1|') + +} + + # This is the definitive site and incredibly slow -HBASE_DIST="http://archive.apache.org/dist/hbase" +HBASE_ORIG_DIST="http://archive.apache.org/dist/hbase" +HBASE_DIST=$HBASE_ORIG_DIST # This is a mirror site and faster but every new release breaks all # existing links. # HBASE_DIST="https://www-us.apache.org/dist/hbase" +# Uncomment this line to download from the closest site: +#export USE_DISPATCHER=1 # Prevent initramfs updates from trying to run grub and lilo. export INITRD=no export DEBIAN_FRONTEND=noninteractive -export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64 - -minimal_apt_get_args='-y --no-install-recommends' +export JAVA_HOME=/usr/lib/jvm/default-jvm ## Build time dependencies ## -HBASE_BUILD_PACKAGES="curl" +HBASE_BUILD_PACKAGES="curl gnupg" # Core list from docs #HBASE_BUILD_PACKAGES="$HBASE_BUILD_PACKAGES " diff --git a/prepare-hbase.sh b/prepare-hbase.sh index 65869ab..bf2e9ee 100755 --- a/prepare-hbase.sh +++ b/prepare-hbase.sh @@ -1,11 +1,29 @@ -#!/bin/sh -x +#!/bin/sh -xe . /build/config-hbase.sh -apt-get update -y - -apt-get install $minimal_apt_get_args $HBASE_BUILD_PACKAGES +apk update +apk add bash $HBASE_BUILD_PACKAGES +mkdir -p /opt cd /opt -curl -SL $HBASE_DIST/$HBASE_VERSION/hbase-$HBASE_VERSION-bin.tar.gz | tar -x -z && mv hbase-${HBASE_VERSION} hbase +if [ -n $USE_DISPATCHER ] +then + HBASE_DIST=$(get_closest_site) +fi + +# download package +curl -SLO $HBASE_DIST/$HBASE_VERSION/hbase-$HBASE_VERSION-bin.tar.gz +# download PGP keys +curl -SLO $HBASE_ORIG_DIST/KEYS +# download checksum +curl -SL $HBASE_ORIG_DIST/$HBASE_VERSION/hbase-$HBASE_VERSION-bin.tar.gz.asc -o download.asc + +# validate the version +gpg --import KEYS +gpg --verify download.asc hbase-$HBASE_VERSION-bin.tar.gz + +# finally unpack and cleanup +tar xzf hbase-$HBASE_VERSION-bin.tar.gz && mv hbase-${HBASE_VERSION} hbase +rm -f hbase-$HBASE_VERSION-bin.tar.gz KEYS download.asc From c0beddfd027aefac4aec6aa7cc647c15b5c95d05 Mon Sep 17 00:00:00 2001 From: mbarison Date: Thu, 15 Feb 2018 13:40:39 -0500 Subject: [PATCH 2/2] add custom service name --- replace-hostname | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/replace-hostname b/replace-hostname index 14b56bb..a5f9261 100755 --- a/replace-hostname +++ b/replace-hostname @@ -12,6 +12,9 @@ declare -a files=( '/opt/hbase/conf/zoo.cfg' ) +# enable custom replacement (e.g. service name on k8s) +REPLACEMENT=${HBASE_SERVICE_NAME:-$HOSTNAME} + for file in "${files[@]}"; do if [ -f "${file}.bak" ]; then cp "${file}.bak" "${file}" @@ -19,5 +22,5 @@ for file in "${files[@]}"; do cp "${file}" "${file}.bak" fi - sed -i "s/hbase-docker/${HOSTNAME}/g" "${file}" + sed -i "s/hbase-docker/${REPLACEMENT}/g" "${file}" done