Base Image Dockerfile
FROM tomcat
RUN rm -rf $CATALINA_HOME/webapps/ROOT \
$CATALINA_HOME/webapps/docs \
$CATALINA_HOME/webapps/examples \
$CATALINA_HOME/webapps/host-manager \
$CATALINA_HOME/webapps/manager
COPY aspectjweaver- 1.7 . 3 .jar $CATALINA_HOME/lib/aspectjweaver- 1.7 . 3 .jar
COPY entrypoint.sh $CATALINA_HOME/bin/init.sh
COPY server.xml $CATALINA_HOME/conf/server.xml
ENV JAVA_OPTS -server -XX:+DisableExplicitGC -XX:+UseConcMarkSweepGC \
-Xms1G -Xmx2G -XX:PermSize=1G -XX:MaxPermSize=2G -Xdebug -Xrunjdwp:transport=dt_socket,address= 8003 ,server=y,suspend=n \
-javaagent:$CATALINA_HOME/lib/aspectjweaver- 1.7 . 3 .jar
ADD https:
RUN unzip /tmp/consul.zip -d /usr/bin/
RUN rm /tmp/*.zip
CMD envconsul -config /conf/cnvconsul/envconsul.cfg init.sh
|
Line 1 specifies docker to build new image based on tomcat official image. While building docker pulls tomcat official image from docker repo.
Line 2 deletes tomcat default webapps.
Line 3, 4, 5 copies/updates files of base image
Line 6 sets JAVA_OPTIONS
Line 7 to 9 downloads envconsul and configures it.
Line 10 specifies the command to excute when docker is run. This starts envconsul and provides init.sh as script to run for envconsul. This makes all configuration pulled by envconsul as environment variables for init.sh.
init.sh
#!/bin/bash
#printenv
catalina.sh run
|
The above just runs catalina.sh
envconsul.cfg
consul = "54.175.240.64:8500"
max_stale = "10m"
timeout = "5s"
retry = "10s"
sanitize = false
splay = "5s"
kill_signal = "SIGHUP"
prefix {
path = "config/CLIP/clip-ui/DEV/common"
}
prefix {
path = "config/CLIP/clip-ui/DEV/console"
}
syslog {
enabled = false
facility = "LOCAL5"
}
|
The above is to build the docker tomcat image. Run command "docker build -t clip/tomcat ." command in the same folder as docker file to create base image.
No comments:
Post a Comment