Skip to content

Commit

Permalink
优化flume and tomcat 的镜像构建脚本
Browse files Browse the repository at this point in the history
  • Loading branch information
supermy committed Jul 6, 2015
1 parent de9bbe7 commit c8114ea
Show file tree
Hide file tree
Showing 6 changed files with 102 additions and 7 deletions.
22 changes: 17 additions & 5 deletions common/myflume/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,30 @@
FROM probablyfine/flume:latest
FROM supermy/docker-jre:7

#FROM probablyfine/flume:latest

RUN mkdir /opt/flume
RUN wget -qO- http://archive.apache.org/dist/flume/1.5.0/apache-flume-1.5.0-bin.tar.gz \
| tar zxvf - -C /opt/flume --strip 1


COPY conf /var/tmp/
COPY lib /opt/flume/lib/

#RUN apt-get install netcat telnet -q -y

RUN ls -hl /opt/flume/lib

RUN ls -hl /var/tmp/
#RUN ls -hl /opt/flume/lib
#RUN ls -hl /var/tmp/


RUN cat /etc/hosts

RUN echo "192.168.59.103 hbasemasteripc" >> /etc/hosts


ADD start-flume.sh /opt/flume/bin/start-flume

ENV JAVA_HOME /opt/java
ENV PATH /opt/flume/bin:/opt/java/bin:$PATH

CMD [ "start-flume" ]

EXPOSE 44444
16 changes: 16 additions & 0 deletions common/myflume/start-flume.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash


FLUME_CONF_DIR=${FLUME_CONF_DIR:-/opt/flume/conf}

[[ -z "${FLUME_CONF_FILE}" ]] && { echo "FLUME_CONF_FILE required"; exit 1; }
[[ -z "${FLUME_AGENT_NAME}" ]] && { echo "FLUME_AGENT_NAME required"; exit 1; }

echo "Starting flume agent : ${FLUME_AGENT_NAME}"

flume-ng agent \
-c ${FLUME_CONF_DIR} \
-f ${FLUME_CONF_FILE} \
-n ${FLUME_AGENT_NAME} \
-Dflume.root.logger=INFO,console

3 changes: 2 additions & 1 deletion common/mykafka/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ FROM supermy/docker-jre:7

MAINTAINER supermy

RUN apt-get update && apt-get install -y unzip
#RUN apt-get update &&
RUN apt-get install -y unzip

#http://mirrors.cnnic.cn/apache/kafka/0.8.2.1/kafka_2.11-0.8.2.1.tgz -O /tmp/kafka_2.11-0.8.2.1.tgz
#http://apache.fayea.com/kafka/0.8.2.1/kafka_2.11-0.8.2.1.tgz
Expand Down
32 changes: 31 additions & 1 deletion web+app/mytomcat/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,34 @@
FROM tutum/tomcat:7.0
FROM supermy/docker-jre:7

#FROM tutum/tomcat:7.0


#RUN apt-get update && \
# apt-get install -yq --no-install-recommends wget pwgen ca-certificates && \
# apt-get clean && \
# rm -rf /var/lib/apt/lists/*

ENV TOMCAT_MAJOR_VERSION 7
ENV TOMCAT_MINOR_VERSION 7.0.62
ENV CATALINA_HOME /tomcat

# INSTALL TOMCAT
RUN wget -q https://archive.apache.org/dist/tomcat/tomcat-${TOMCAT_MAJOR_VERSION}/v${TOMCAT_MINOR_VERSION}/bin/apache-tomcat-${TOMCAT_MINOR_VERSION}.tar.gz && \
wget -qO- https://archive.apache.org/dist/tomcat/tomcat-${TOMCAT_MAJOR_VERSION}/v${TOMCAT_MINOR_VERSION}/bin/apache-tomcat-${TOMCAT_MINOR_VERSION}.tar.gz.md5 | md5sum -c - && \
tar zxf apache-tomcat-*.tar.gz && \
rm apache-tomcat-*.tar.gz && \
mv apache-tomcat* tomcat

ADD create_tomcat_admin_user.sh /create_tomcat_admin_user.sh
ADD run.sh /run.sh
RUN chmod +x /*.sh

EXPOSE 8080
CMD ["/run.sh"]

#--------------------


COPY dbtest /tomcat/webapps/dbtest
COPY dbtest /home/dbtest
COPY lib-cluster/* /tomcat/lib/
Expand Down
29 changes: 29 additions & 0 deletions web+app/mytomcat/create_tomcat_admin_user.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash

if [ -f /.tomcat_admin_created ]; then
echo "Tomcat 'admin' user already created"
exit 0
fi

#generate password
PASS=${TOMCAT_PASS:-$(pwgen -s 12 1)}
_word=$( [ ${TOMCAT_PASS} ] && echo "preset" || echo "random" )

echo "=> Creating and admin user with a ${_word} password in Tomcat"
sed -i -r 's/<\/tomcat-users>//' ${CATALINA_HOME}/conf/tomcat-users.xml
echo '<role rolename="manager-gui"/>' >> ${CATALINA_HOME}/conf/tomcat-users.xml
echo '<role rolename="manager-script"/>' >> ${CATALINA_HOME}/conf/tomcat-users.xml
echo '<role rolename="manager-jmx"/>' >> ${CATALINA_HOME}/conf/tomcat-users.xml
echo '<role rolename="admin-gui"/>' >> ${CATALINA_HOME}/conf/tomcat-users.xml
echo '<role rolename="admin-script"/>' >> ${CATALINA_HOME}/conf/tomcat-users.xml
echo "<user username=\"admin\" password=\"${PASS}\" roles=\"manager-gui,manager-script,manager-jmx,admin-gui, admin-script\"/>" >> ${CATALINA_HOME}/conf/tomcat-users.xml
echo '</tomcat-users>' >> ${CATALINA_HOME}/conf/tomcat-users.xml
echo "=> Done!"
touch /.tomcat_admin_created

echo "========================================================================"
echo "You can now configure to this Tomcat server using:"
echo ""
echo " admin:${PASS}"
echo ""
echo "========================================================================"
7 changes: 7 additions & 0 deletions web+app/mytomcat/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

if [ ! -f /.tomcat_admin_created ]; then
/create_tomcat_admin_user.sh
fi

exec ${CATALINA_HOME}/bin/catalina.sh run

0 comments on commit c8114ea

Please sign in to comment.