From ee1825ec0f67d33d8f1609bcdb6d5e35f075ff3f Mon Sep 17 00:00:00 2001 From: Brandon Williams Date: Thu, 17 Aug 2023 09:54:05 -0500 Subject: [PATCH] Add newrelic agent to keycloak --- docker-compose.yaml | 3 +++ services/keycloak/Dockerfile | 7 ++++++- services/keycloak/startup-scripts/10-newrelic.sh | 12 ++++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) create mode 100755 services/keycloak/startup-scripts/10-newrelic.sh diff --git a/docker-compose.yaml b/docker-compose.yaml index c5590ff565..4b4553b951 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -132,6 +132,9 @@ services: - '8088:8080' environment: - KEYCLOAK_ADMIN_EMAIL=admin@example.com + # Uncomment for local new relic tracking + # - NEW_RELIC_LICENSE_KEY= + # - NEW_RELIC_APP_NAME=keycloak-local volumes: - "./services/keycloak/profile.properties:/opt/jboss/keycloak/standalone/configuration/profile.properties" - "./services/keycloak/startup-scripts:/opt/jboss/startup-scripts" diff --git a/services/keycloak/Dockerfile b/services/keycloak/Dockerfile index 8b4db9d4e2..5bcbc036ec 100644 --- a/services/keycloak/Dockerfile +++ b/services/keycloak/Dockerfile @@ -15,7 +15,7 @@ ENV LAGOON_VERSION=$LAGOON_VERSION USER root -RUN microdnf install -y nc jq \ +RUN microdnf install -y nc jq unzip \ && microdnf clean all \ && rm -rf /var/cache/yum @@ -40,6 +40,11 @@ RUN rm -f /bin/sh && ln -s /bin/bash /bin/sh RUN architecture=$(case $(uname -m) in x86_64 | amd64) echo "amd64" ;; aarch64 | arm64 | armv8) echo "arm64" ;; *) echo "amd64" ;; esac) \ && curl -sL https://github.com/krallin/tini/releases/download/v0.19.0/tini-${architecture} -o /sbin/tini && chmod a+x /sbin/tini +RUN cd /opt \ + && curl -O https://download.newrelic.com/newrelic/java-agent/newrelic-agent/current/newrelic-java.zip \ + && unzip newrelic-java.zip \ + && rm newrelic-java.zip + ENV TMPDIR=/tmp \ TMP=/tmp \ HOME=/home \ diff --git a/services/keycloak/startup-scripts/10-newrelic.sh b/services/keycloak/startup-scripts/10-newrelic.sh new file mode 100755 index 0000000000..9b930dd0a0 --- /dev/null +++ b/services/keycloak/startup-scripts/10-newrelic.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +if [ -v NEW_RELIC_LICENSE_KEY ] +then + echo "Enabling newrelic monitor" + + cat << 'EOF' >> /opt/jboss/keycloak/bin/standalone.conf + +JAVA_OPTS="$JAVA_OPTS -javaagent:/opt/newrelic/newrelic.jar" +EOF + +fi