switch to Java 8 + cleanup

This commit is contained in:
Xavier Léauté 2015-11-12 17:28:56 -08:00
parent 8fa34ee671
commit 350fdbeec1
1 changed files with 41 additions and 32 deletions

View File

@ -1,15 +1,15 @@
FROM ubuntu:14.04 FROM ubuntu:14.04
# Add Java 7 repository # Java 8
RUN apt-get update RUN apt-get update \
RUN apt-get install -y software-properties-common && apt-get install -y software-properties-common \
RUN apt-add-repository -y ppa:webupd8team/java && apt-add-repository -y ppa:webupd8team/java \
RUN apt-get update && apt-get purge --auto-remove -y software-properties-common \
&& apt-get update \
# Oracle Java 7 && echo oracle-java-8-installer shared/accepted-oracle-license-v1-1 select true | /usr/bin/debconf-set-selections \
RUN echo oracle-java-7-installer shared/accepted-oracle-license-v1-1 select true | /usr/bin/debconf-set-selections && apt-get install -y oracle-java8-installer \
RUN apt-get install -y oracle-java7-installer && apt-get install -y oracle-java8-set-default \
RUN apt-get install -y oracle-java7-set-default && rm -rf /var/cache/oracle-jdk8-installer
# MySQL (Metadata store) # MySQL (Metadata store)
RUN apt-get install -y mysql-server RUN apt-get install -y mysql-server
@ -18,43 +18,51 @@ RUN apt-get install -y mysql-server
RUN apt-get install -y supervisor RUN apt-get install -y supervisor
# Zookeeper # Zookeeper
RUN wget -q -O - http://www.us.apache.org/dist/zookeeper/zookeeper-3.4.6/zookeeper-3.4.6.tar.gz | tar -xzf - -C /usr/local RUN wget -q -O - http://www.us.apache.org/dist/zookeeper/zookeeper-3.4.6/zookeeper-3.4.6.tar.gz | tar -xzf - -C /usr/local \
RUN cp /usr/local/zookeeper-3.4.6/conf/zoo_sample.cfg /usr/local/zookeeper-3.4.6/conf/zoo.cfg && cp /usr/local/zookeeper-3.4.6/conf/zoo_sample.cfg /usr/local/zookeeper-3.4.6/conf/zoo.cfg \
RUN ln -s /usr/local/zookeeper-3.4.6 /usr/local/zookeeper && ln -s /usr/local/zookeeper-3.4.6 /usr/local/zookeeper
# Kafka # Kafka
RUN wget -q -O - http://www.us.apache.org/dist/kafka/0.8.2.0/kafka_2.10-0.8.2.0.tgz | tar -xzf - -C /usr/local RUN wget -q -O - http://www.us.apache.org/dist/kafka/0.8.2.0/kafka_2.10-0.8.2.0.tgz | tar -xzf - -C /usr/local \
RUN ln -s /usr/local/kafka_2.10-0.8.2.0 /usr/local/kafka && ln -s /usr/local/kafka_2.10-0.8.2.0 /usr/local/kafka
# unless advertised.host.name is set to docker ip, publishing data fails
ADD docker_ip docker_ip
RUN perl -pi -e "s/#advertised.port=.*/advertised.port=9092/; s/#advertised.host.*/advertised.host.name=$(cat docker_ip)/" /usr/local/kafka/config/server.properties
# git
RUN apt-get install -y git
# Druid system user # Druid system user
RUN adduser --system --group --no-create-home druid RUN adduser --system --group --no-create-home druid \
RUN mkdir -p /var/lib/druid && mkdir -p /var/lib/druid \
RUN chown druid:druid /var/lib/druid && chown druid:druid /var/lib/druid
# Add druid jars # clean up time
ADD lib/* /usr/local/druid/lib/ RUN apt-get clean \
&& rm -rf /tmp/* \
/var/tmp/* \
/var/lib/apt/lists \
/root/.m2
WORKDIR /
# Setup metadata store # Setup metadata store
RUN /etc/init.d/mysql start && echo "GRANT ALL ON druid.* TO 'druid'@'%' IDENTIFIED BY 'diurd'; CREATE database druid DEFAULT CHARACTER SET utf8;" | mysql -u root && /etc/init.d/mysql stop RUN /etc/init.d/mysql start \
&& echo "GRANT ALL ON druid.* TO 'druid'@'%' IDENTIFIED BY 'diurd'; CREATE database druid DEFAULT CHARACTER SET utf8;" | mysql -u root \
&& /etc/init.d/mysql stop
# Add Druid jars
ADD lib/* /usr/local/druid/lib/
# Add sample data # Add sample data
RUN /etc/init.d/mysql start && java -Ddruid.metadata.storage.type=mysql -cp "/usr/local/druid/lib/*" io.druid.cli.Main tools metadata-init --connectURI="jdbc:mysql://localhost:3306/druid" --user=druid --password=diurd && /etc/init.d/mysql stop RUN /etc/init.d/mysql start \
&& java -cp "/usr/local/druid/lib/*" -Ddruid.metadata.storage.type=mysql io.druid.cli.Main tools metadata-init --connectURI="jdbc:mysql://localhost:3306/druid" --user=druid --password=diurd \
&& /etc/init.d/mysql stop
ADD sample-data.sql sample-data.sql ADD sample-data.sql sample-data.sql
RUN /etc/init.d/mysql start && cat sample-data.sql | mysql -u root druid && /etc/init.d/mysql stop RUN /etc/init.d/mysql start \
&& cat sample-data.sql | mysql -u root druid \
&& /etc/init.d/mysql stop
# Setup supervisord # Setup supervisord
ADD supervisord.conf /etc/supervisor/conf.d/supervisord.conf ADD supervisord.conf /etc/supervisor/conf.d/supervisord.conf
# Clean up # unless advertised.host.name is set to docker host ip, publishing data fails
RUN apt-get clean && rm -rf /tmp/* /var/tmp/* # run this last to avoid rebuilding the image every time the ip changes
ADD docker_ip docker_ip
RUN perl -pi -e "s/#advertised.port=.*/advertised.port=9092/; s/#advertised.host.*/advertised.host.name=$(cat docker_ip)/" /usr/local/kafka/config/server.properties
# Expose ports: # Expose ports:
# - 8081: HTTP (coordinator) # - 8081: HTTP (coordinator)
@ -73,5 +81,6 @@ EXPOSE 8091
EXPOSE 3306 EXPOSE 3306
EXPOSE 2181 2888 3888 EXPOSE 2181 2888 3888
EXPOSE 8100 8101 8102 8103 8104 EXPOSE 8100 8101 8102 8103 8104
WORKDIR /var/lib/druid WORKDIR /var/lib/druid
ENTRYPOINT export HOST_IP="$(resolveip -s $HOSTNAME)" && exec /usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf ENTRYPOINT export HOST_IP="$(resolveip -s $HOSTNAME)" && exec /usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf