<gh_stars>0
FROM ubuntu:14.04

WORKDIR /root
ENV USER=root

RUN apt-get update && apt-get install -y software-properties-common openssh-server wget

# Install Oracle's Java
ENV JAVA_HOME=/usr/lib/jvm/java-8-oracle
RUN add-apt-repository -y ppa:webupd8team/java && apt-get update && \
    echo "oracle-java8-installer shared/accepted-oracle-license-v1-1 select true" | debconf-set-selections && \
    apt-get install -y oracle-java8-installer

# Install Hadoop
ENV HADOOP_VERSION=2.7.3
ENV HADOOP_HOME=/usr/local/hadoop
ENV HADOOP_INSTALL=$HADOOP_HOME
ENV HADOOP_PREFIX=$HADOOP_HOME
ENV HADOOP_MAPRED_HOME=$HADOOP_HOME
ENV HADOOP_COMMON_HOME=$HADOOP_HOME
ENV HADOOP_HDFS_HOME=$HADOOP_HOME
ENV HADOOP_CONF_DIR=$HADOOP_INSTALL/etc/hadoop
ENV YARN_HOME=$HADOOP_HOME
ENV LD_LIBRARY_PATH=/usr/local/hadoop/lib/native
ENV PATH=$PATH:$HADOOP_HOME/bin:$HADOOP_HOME/sbin
RUN wget http://www-us.apache.org/dist/hadoop/common/hadoop-$HADOOP_VERSION/hadoop-$HADOOP_VERSION.tar.gz && \
    tar xfz hadoop-$HADOOP_VERSION.tar.gz && \
    mv hadoop-$HADOOP_VERSION $HADOOP_HOME && \
    rm hadoop-$HADOOP_VERSION.tar.gz

# Configure hadoop
COPY config/* /tmp/
RUN sed -i "s/\${JAVA_HOME}/\/usr\/lib\/jvm\/java-8-oracle/" $HADOOP_CONF_DIR/hadoop-env.sh && \
    mv /tmp/hdfs-site.xml $HADOOP_CONF_DIR/hdfs-site.xml && \
    mv /tmp/core-site.xml $HADOOP_CONF_DIR/core-site.xml && \
    mv /tmp/yarn-site.xml $HADOOP_CONF_DIR/yarn-site.xml && \
    mv /tmp/mapred-site.xml $HADOOP_CONF_DIR/mapred-site.xml

# Configure SSH
RUN ssh-keygen -t rsa -f ~/.ssh/id_rsa -P '' && \
    cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys && \
    sed -i "s/#   StrictHostKeyChecking ask/    StrictHostKeyChecking no/" /etc/ssh/ssh_config

# Add init scripts
COPY scripts/* /usr/bin/
RUN chmod a+x /usr/bin/init-hadoop-master.sh && \
    chmod a+x /usr/bin/init-hadoop-slave.sh
