Skip to content

Instantly share code, notes, and snippets.

@ghusta
Last active February 6, 2019 18:19
Show Gist options
  • Save ghusta/95c5038dc1649ba98b3067786d226d35 to your computer and use it in GitHub Desktop.
Save ghusta/95c5038dc1649ba98b3067786d226d35 to your computer and use it in GitHub Desktop.
Tomcat 8 + Docker : add custom directory in classpath (Method #2 : define CLASSPATH in bin/setenv.sh)
FROM tomcat:8.5-jre8
# $CATALINA_HOME is defined in tomcat image
ADD target/my-webapp*.war $CATALINA_HOME/webapps/my-webapp.war
# Application config
RUN mkdir $CATALINA_HOME/app_conf/
ADD src/main/config/test.properties $CATALINA_HOME/app_conf/
# Create "$CATALINA_HOME/bin/setenv.sh"
# Escape char : https://docs.docker.com/engine/reference/builder/#/escape
RUN echo "# Add app_conf to Tomcat CLASSPATH" > $CATALINA_HOME/bin/setenv.sh
RUN echo "CLASSPATH=\$CATALINA_HOME/app_conf/" >> $CATALINA_HOME/bin/setenv.sh
RUN chmod 750 $CATALINA_HOME/bin/setenv.sh
# Check : docker exec my-webapp cat /usr/local/tomcat/bin/setenv.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment