diff --git a/services/git-bridge/Dockerfile b/services/git-bridge/Dockerfile index 0c28bfe5fa..9de0342f0b 100644 --- a/services/git-bridge/Dockerfile +++ b/services/git-bridge/Dockerfile @@ -28,6 +28,16 @@ FROM openjdk:11-jre RUN apt-get update && apt-get install -y git sqlite3 procps htop net-tools sockstat \ && rm -rf /var/lib/apt/lists +# Install Google Cloud Profiler agent +RUN mkdir -p /opt/cprof && \ + wget -q -O- https://storage.googleapis.com/cloud-profiler/java/latest/profiler_java_agent.tar.gz \ + | tar xzv -C /opt/cprof + +# Install Google Cloud Debugger agent +RUN mkdir /opt/cdbg && \ + wget -qO- https://storage.googleapis.com/cloud-debugger/compute-java/debian-wheezy/cdbg_java_agent_gce.tar.gz | \ + tar xvz -C /opt/cdbg + RUN useradd --create-home node COPY --from=builder /git-bridge.jar / diff --git a/services/git-bridge/start.sh b/services/git-bridge/start.sh index bb4dd362be..47547ae8b6 100755 --- a/services/git-bridge/start.sh +++ b/services/git-bridge/start.sh @@ -1,8 +1,17 @@ #!/bin/bash + /opt/envsubst < /envsubst_template.json > /conf/runtime.json if [ "x$GIT_BRIDGE_JVM_ARGS" == "x" ]; then GIT_BRIDGE_JVM_ARGS="-XX:+UseContainerSupport -XX:MaxRAMPercentage=50.0" fi +if [ "$ENABLE_PROFILE_AGENT" == "true" ]; then + GIT_BRIDGE_JVM_ARGS="-agentpath:/opt/cprof/profiler_java_agent.so=-cprof_service=git-bridge,-cprof_service_version=1.0.0,-cprof_enable_heap_sampling=true ${GIT_BRIDGE_JVM_ARGS}" +fi + +if [ "$ENABLE_DEBUG_AGENT" == "true" ]; then + GIT_BRIDGE_JVM_ARGS="-agentpath:/opt/cdbg/cdbg_java_agent.so -Dcom.google.cdbg.module=git-bridge -Dcom.google.cdbg.version=$(date +%y%m%d%H%M%S) ${GIT_BRIDGE_JVM_ARGS}" +fi + exec java $GIT_BRIDGE_JVM_ARGS -jar /git-bridge.jar /conf/runtime.json