-
Notifications
You must be signed in to change notification settings - Fork 201
Using Application Insights in a Dockerfile (2.x)
Trask Stalnaker edited this page Jan 20, 2021
·
1 revision
This example uses the Tomcat base image. The implementation will vary slightly depending on the chosen application server. Refer to that application server's documentation regarding the proper procedures for adding -javaagent
to the JVM options.
This assumes a WAR file deployment which has a dependency on applicationinsights-web and has the WebRequestTrackingFilter configured. See the documentation for more details on building your application.
FROM tomcat:8.5-jre8
# The next two ENV declarations are optional, but make it easier when upgrading
# Replace this with the current version
ENV APPINSIGHTS_VERSION 2.3.0
ENV AGENT_JAR_NAME applicationinsights-agent-${APPINSIGHTS_VERSION}.jar
# You may choose to download the agent jar directly using curl or wget.
# This example assumes it already exists in the same directory as the dockerfile
# The destination directory location is mostly arbitrary, but should exist outside the Tomcat's and your application's classpath.
COPY ./${AGENT_JAR_NAME} /opt/aiagent/
COPY ./AI-Agent.xml /opt/aiagent/
# This next file is the recommended mechanism for modifying Tomcat's JVM options;
# but an ENV CATALINA_OPTS declaration would also work
COPY ./setenv.sh $CATALINA_HOME/bin/setenv.sh
# Place commands for your application files here; probably including copying a WAR file into $CATALINA_HOME/webapps
# CMD from the base image. nothing needs to change here.
CMD ["catalina.sh", "run"]
#!/usr/bin/env bash
CATALINA_OPTS="-javaagent:/opt/aiagent/$AGENT_JAR_NAME $CATALINA_OPTS"