Skip to content

Commit

Permalink
Merge pull request #3528 from uselagoon/newrelic
Browse files Browse the repository at this point in the history
Add newrelic agent to keycloak
  • Loading branch information
tobybellwood authored Sep 1, 2023
2 parents c08dcce + ee1825e commit 4a83e1f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
3 changes: 3 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
7 changes: 6 additions & 1 deletion services/keycloak/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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 \
Expand Down
12 changes: 12 additions & 0 deletions services/keycloak/startup-scripts/10-newrelic.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 4a83e1f

Please sign in to comment.