From 0f515a389416f76284cf6679e8967302754ac058 Mon Sep 17 00:00:00 2001 From: Gabriel Roldan Date: Fri, 19 Jan 2024 23:05:29 -0300 Subject: [PATCH] Install Yourkit Java Profiler agent in the geoserver base image Allow profiling the applications directly from the containers --- .env.yjp.example | 17 +++++++++++++++++ .gitignore | 3 +++ docker-compose.yml | 1 + src/apps/base-images/geoserver/Dockerfile | 9 +++++++++ 4 files changed, 30 insertions(+) create mode 100644 .env.yjp.example diff --git a/.env.yjp.example b/.env.yjp.example new file mode 100644 index 000000000..5e721247b --- /dev/null +++ b/.env.yjp.example @@ -0,0 +1,17 @@ +# This is a sample docker compose env file to run the geoserver services +# with the Yourkit Java Profiles connection broker. +# Copy as .yjp.env and replace and with the values +# sent to you by email. +# Then run with docker compose --env-file .env --env-file .env.yjp -f ... up -d +# See https://www.yourkit.com/docs/connection-broker/2023.9/help/ + +YJP_OPTS=-agentpath:/usr/local/YourKit-JavaProfiler-2023.9/bin/linux-x86-64/libyjpagent.so=broker_url=https://broker.yourkit.com//,broker_token= + +WFS_JAVA_OPTS=$YJP_OPTS,sessionname=wfs-service +WMS_JAVA_OPTS=$YJP_OPTS,sessionname=wms-service +WCS_JAVA_OPTS=$YJP_OPTS,sessionname=wcs-service +WPS_JAVA_OPTS=$YJP_OPTS,sessionname=wps-service +REST_JAVA_OPTS=$YJP_OPTS,sessionname=rest-service +WEBUI_JAVA_OPTS=$YJP_OPTS,sessionname=webui-service +GWC_JAVA_OPTS=$YJP_OPTS,sessionname=gwc-service + diff --git a/.gitignore b/.gitignore index 2146ed07c..9f75f82aa 100644 --- a/.gitignore +++ b/.gitignore @@ -38,3 +38,6 @@ docker-compose_datadir* /.metadata/ .vscode + +# Yourkit Java Profiler docker compose env file with private token +.env.yjp diff --git a/docker-compose.yml b/docker-compose.yml index d98da6be2..8d23b9f00 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -299,6 +299,7 @@ services: - discovery environment: SPRING_PROFILES_ACTIVE: "${GEOSERVER_DEFAULT_PROFILES}" + JAVA_OPTS: "${GWC_JAVA_OPTS}" RETRY_MAX_ATTEMPTS: 100 networks: - gs-cloud-network diff --git a/src/apps/base-images/geoserver/Dockerfile b/src/apps/base-images/geoserver/Dockerfile index a9ae9724a..3d376a77c 100644 --- a/src/apps/base-images/geoserver/Dockerfile +++ b/src/apps/base-images/geoserver/Dockerfile @@ -2,10 +2,16 @@ ARG TAG=latest FROM geoservercloud/gs-cloud-base-jre:$TAG as builder ARG JAR_FILE=target/gs-cloud-*-bin.jar +RUN apt update && apt install -y --no-install-recommends unzip + COPY ${JAR_FILE} application.jar RUN java -Djarmode=layertools -jar application.jar extract +RUN wget -q https://www.yourkit.com/download/docker/YourKit-JavaProfiler-2023.9-docker.zip -P /tmp/ && \ + unzip /tmp/YourKit-JavaProfiler-2023.9-docker.zip -d /tmp && \ + rm /tmp/YourKit-JavaProfiler-2023.9-docker.zip + ########## FROM geoservercloud/gs-cloud-base-spring-boot:$TAG @@ -25,6 +31,8 @@ fonts-roboto \ && rm -rf /var/cache/apt/* \ && rm -rf /var/lib/apt/lists/* +COPY --from=builder /tmp/YourKit-JavaProfiler-2023.9 /usr/local/YourKit-JavaProfiler-2023.9 + RUN mkdir -p /opt/app/data_directory /data/geowebcache \ && chmod 0777 /opt/app/data_directory /data/geowebcache @@ -36,3 +44,4 @@ WORKDIR /opt/app/bin COPY --from=builder dependencies/ ./ COPY --from=builder snapshot-dependencies/ ./ COPY --from=builder spring-boot-loader/ ./ +