Skip to content

Instantly share code, notes, and snippets.

@jaycdave88
Last active May 26, 2022 18:16
Show Gist options
  • Save jaycdave88/b553a66706761dcd65e9df9bb4b14e3a to your computer and use it in GitHub Desktop.
Save jaycdave88/b553a66706761dcd65e9df9bb4b14e3a to your computer and use it in GitHub Desktop.
Datadog Java ECS Fargate Dockerfile & Entrypoint.sh
#BASE CONATINER AMAZON JAVA 8
FROM 415971912945.dkr.ecr.us-west-2.amazonaws.com/amazoncorretto:8-al2-full
# BUILD TIME ARGUMENTS
ARG SERVICE_NAME
#ADD jq for entrypoint.sh
RUN yum install jq -y
RUN yum install unzip -y
# ADD entrypoint.sh
COPY entrypoint.sh /app/entrypoint.sh
RUN chmod +x /app/entrypoint.sh
# ADD EXECUATABLe JAR
WORKDIR /app
COPY *.jar /app/service.jar
# ADD OPEN TELEMETRY JAR
ADD https://github.com/aws-observability/aws-otel-java-instrumentation/releases/download/v1.9.0/aws-opentelemetry-agent.jar /app/aws-opentelemetry-agent.jar
ENV OTEL_RESOURCE_ATTRIBUTES "service.namespace=${SERVICE_NAME}-namespace,service.name=${SERVICE_NAME}"
ENV OTEL_IMR_EXPORT_INTERVAL "10000"
# ADD APP DYNAMICS
# S3 bucket present in unqualified cicd acount, since CICD accounts dont have on prem access so unable use nexus repo location
# COPY appagent-21.11.3.33314.zip /app/appagent-21.11.3.33314.zip
# RUN unzip /app/appagent-21.11.3.33314.zip
# ENV SERVICE_NAME ${SERVICE_NAME}
# ADD DATADOG JAVA APM AGENT
# Description: Following the path for the install of AppD. Where the AppD APM binary is hosted within S3.
# COPY dd-java-agent.jar /app/dd-java-agent.jar
# Description: Setting the Datadog APM agent (via ENV Vars) & mapping the values from the application task definition.
# ENV DD_SERVICE_NAME ${SERVICE_NAME}
# ENV DD_ENV ${ENVIRONMENT}
ENTRYPOINT ["/app/entrypoint.sh"]
---
#Entrypoint.sh start
if $ENABLE_DATADOG_JAVA_APM_AGENT ; then
JAVA_OPTS="$JAVA_OPTS -javaagent:/app/dd-java-agent.jar \
-Ddd.service=${SERVICE_NAME} \
-Ddd.env=${ENVIRONMENT} \
-Ddd.version=${APP_VERSION} \
-Ddd.logs.injection=${IS_LOGS_INJECTION_ENABLED} \
-Ddd.profiling.enabled=${IS_CODE_PROFILING_ENABLED}
fi
#Entrypoint.sh end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment