Skip to content

Commit 50a0773

Browse files
authored
Merge pull request #2 from greatestusername-splunk/hybrid-apm
Hybrid apm merging in the repo
2 parents 322d328 + 0cfdb5e commit 50a0773

27 files changed

+3366
-0
lines changed

src/shop-dc-shim/Dockerfile

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# Copyright The OpenTelemetry Authors
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
# Multi-stage build for Java Spring Boot application (Enterprise N-Tier)
5+
FROM eclipse-temurin:21-jdk AS builder
6+
7+
WORKDIR /app
8+
COPY ./build.gradle build.gradle
9+
COPY ./settings.gradle settings.gradle
10+
COPY ./gradle gradle
11+
COPY ./gradlew gradlew
12+
COPY ./src src
13+
14+
# Build the application
15+
RUN chmod +x ./gradlew
16+
RUN ./gradlew build -x test
17+
18+
# Production image with enterprise monitoring agents
19+
FROM eclipse-temurin:21-jre
20+
21+
# Install enterprise tooling
22+
RUN apt-get update && apt-get install -y curl bash jq net-tools unzip dumb-init && rm -rf /var/lib/apt/lists/*
23+
24+
WORKDIR /app
25+
26+
# Create application user
27+
RUN groupadd -g 1001 shopdc && \
28+
useradd -r -u 1001 -g shopdc shopdc
29+
30+
# Create directories for monitoring agents
31+
ENV APPDYNAMICS_AGENT_BASE_DIR=/opt/appdynamics
32+
ENV OPENTELEMETRY_AGENT_DIR=/opt/opentelemetry
33+
34+
RUN mkdir -p $APPDYNAMICS_AGENT_BASE_DIR $OPENTELEMETRY_AGENT_DIR && \
35+
chown -R shopdc:shopdc $APPDYNAMICS_AGENT_BASE_DIR $OPENTELEMETRY_AGENT_DIR
36+
37+
# Download OpenTelemetry Java agent for Splunk Observability andlatest AppDynamics Java agent
38+
ADD --chown=shopdc:shopdc https://github.com/signalfx/splunk-otel-java/releases/latest/download/splunk-otel-javaagent.jar $OPENTELEMETRY_AGENT_DIR/opentelemetry-javaagent.jar
39+
40+
RUN cd /tmp && \
41+
echo "Fetching latest AppDynamics Java agent..." && \
42+
DOWNLOAD_BASE_PATH="https://download-files.appdynamics.com/" && \
43+
echo "Getting latest version info from AppDynamics API..." && \
44+
FILE_PATH=$(curl -s https://download.appdynamics.com/download/downloadfilelatest/ | jq -r '.[].s3_path' | grep java-jdk8 | head -n1) && \
45+
DOWNLOAD_URL="${DOWNLOAD_BASE_PATH}${FILE_PATH}" && \
46+
echo "Downloading AppDynamics agent from: $DOWNLOAD_URL" && \
47+
curl -L -f "$DOWNLOAD_URL" -o JavaAgent.zip && \
48+
echo "Downloaded file info:" && \
49+
ls -la JavaAgent.zip && \
50+
echo "Extracting AppDynamics agent to $APPDYNAMICS_AGENT_BASE_DIR..." && \
51+
unzip -q JavaAgent.zip -d $APPDYNAMICS_AGENT_BASE_DIR && \
52+
echo "AppDynamics agent extracted successfully" && \
53+
ls -la $APPDYNAMICS_AGENT_BASE_DIR/ && \
54+
chown -R shopdc:shopdc $APPDYNAMICS_AGENT_BASE_DIR && \
55+
rm -f JavaAgent.zip
56+
57+
# Copy application JAR and startup script
58+
COPY --from=builder --chown=shopdc:shopdc /app/build/libs/*.jar app.jar
59+
COPY --chown=shopdc:shopdc ./start-app-dual.sh start-app-dual.sh
60+
61+
RUN chmod +x start-app-dual.sh
62+
63+
# Switch to non-root user
64+
USER shopdc
65+
66+
# Environment variables for enterprise deployment
67+
ENV JAVA_OPTS="-Xms512m -Xmx1024m -XX:+UseG1GC -XX:MaxGCPauseMillis=200 -XX:+HeapDumpOnOutOfMemoryError" \
68+
OTEL_JAVAAGENT_ENABLED=true \
69+
APPDYNAMICS_JAVAAGENT_ENABLED=false \
70+
APPDYNAMICS_CONTROLLER_HOST_NAME=se-lab.saas.appdynamics.com \
71+
APPDYNAMICS_CONTROLLER_PORT=443 \
72+
APPDYNAMICS_AGENT_APPLICATION_NAME=shop-dc-shim-service \
73+
APPDYNAMICS_AGENT_TIER_NAME=shop-dc-shim \
74+
APPDYNAMICS_AGENT_NODE_NAME=reuse \
75+
OTEL_SERVICE_NAME=shop-dc-shim \
76+
OTEL_RESOURCE_ATTRIBUTES="service.name=shop-dc-shim,deployment.environment=datacenter-b01,service.namespace=datacenter,service.version=2.1.3" \
77+
AGENT_DEPLOYMENT_MODE=dual \
78+
SPLUNK_PROFILER_ENABLED=true \
79+
SPLUNK_PROFILER_MEMORY_ENABLED=true \
80+
SPLUNK_SNAPSHOT_PROFILER_ENABLED=true \
81+
SPLUNK_SNAPSHOT_SELECTION_PROBABILITY=0.2
82+
83+
# Health check
84+
HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \
85+
CMD curl -f http://localhost:${SHOP_DC_SHIM_PORT:-8070}/actuator/health || exit 1
86+
87+
EXPOSE 8070
88+
89+
# Use dumb-init for proper signal handling in containers
90+
ENTRYPOINT ["dumb-init", "--"]
91+
CMD ["./start-app-dual.sh"]

0 commit comments

Comments
 (0)