<|start_filename|>Dockerfile<|end_filename|>
FROM quay.io/geodocker/hdfs:0.1

MAINTAINER <NAME> <<EMAIL>>

ARG ACCUMULO_VERSION
ENV ACCUMULO_VERSION ${ACCUMULO_VERSION}
ENV ACCUMULO_HOME /opt/accumulo
ENV ACCUMULO_CONF_DIR $ACCUMULO_HOME/conf
ENV ZOOKEEPER_HOME /usr/lib/zookeeper
ENV PATH=$PATH:$ACCUMULO_HOME/bin

ADD accumulo-${ACCUMULO_VERSION}-bin.tar.gz /opt

# Accumulo and Zookeeper client
RUN set -x \
  && mv /opt/accumulo-${ACCUMULO_VERSION} ${ACCUMULO_HOME} \
  && yum install -y make gcc-c++ \
  && bash -c "${ACCUMULO_HOME}/bin/build_native_library.sh" \
  && yum -y autoremove gcc-c++
  # TODO: Clean up after build_native_library

WORKDIR "${ACCUMULO_HOME}"
COPY ./fs /
ENTRYPOINT [ "/sbin/entrypoint.sh" ]


<|start_filename|>Makefile<|end_filename|>
BASE := $(subst -, ,$(notdir ${CURDIR}))
ORG  := $(word 1, ${BASE})
REPO := $(word 2, ${BASE})
IMG  := quay.io/${ORG}/${REPO}
ACCUMULO_VERSION := 1.7.2

build: accumulo-${ACCUMULO_VERSION}-bin.tar.gz
	docker build \
		--build-arg ACCUMULO_VERSION=${ACCUMULO_VERSION} \
		-t ${IMG}:latest .

accumulo-${ACCUMULO_VERSION}-bin.tar.gz:
	curl -L -C - -O "http://apache.mirrors.pair.com/accumulo/${ACCUMULO_VERSION}/accumulo-${ACCUMULO_VERSION}-bin.tar.gz"

publish: build
	docker push ${IMG}:latest
	if [ "${TAG}" != "" -a "${TAG}" != "latest" ]; then docker tag ${IMG}:latest ${IMG}:${TAG} && docker push ${IMG}:${TAG}; fi

test: build
	docker-compose up -d
	docker-compose run --rm accumulo-master bash -c "set -e \
		&& source /sbin/accumulo-lib.sh \
		&& wait_until_accumulo_is_available accumulo zookeeper \
		&& accumulo shell -p GisPwd -e 'info'"
	docker-compose down

clean:

cleaner: clean

cleanest: cleaner
	rm -f accumulo-${ACCUMULO_VERSION}-bin.tar.gz
