forked from davidgeorgehope/custom-instrumentation-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile.elastic
26 lines (17 loc) · 1.09 KB
/
Dockerfile.elastic
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# Build stage
FROM maven:3.8.7-openjdk-18-slim as build
COPY simple-java /home/app/simple-java
COPY elastic-custom-instrumentation /home/app/elastic-custom-instrumentation
WORKDIR /home/app/simple-java
RUN mvn install
WORKDIR /home/app/elastic-custom-instrumentation
RUN mvn install
# Package stage
FROM maven:3.8.7-openjdk-18-slim
COPY --from=build /home/app/simple-java/target/simple-java-1.0-SNAPSHOT.jar /usr/local/lib/simple-java-1.0-SNAPSHOT.jar
COPY --from=build /home/app/elastic-custom-instrumentation/target/my-project-name-jar-with-dependencies.jar /usr/local/lib/my-project-name-jar-with-dependencies.jar
WORKDIR /
RUN curl -L -o elastic-apm-agent.jar "https://oss.sonatype.org/service/local/artifact/maven/redirect?r=releases&g=co.elastic.apm&a=elastic-apm-agent&v=LATEST"
ENV ELASTIC_APM_SERVER_URL=${SERVER_URL}
ENV ELASTIC_APM_SECRET_TOKEN=${SECRET_TOKEN}
CMD ["java", "-javaagent:/elastic-apm-agent.jar", "-Delastic.apm.service_name=my-service-2", "-Delastic.apm.environment=my-environment", "-Delastic.apm.plugins_dir=/usr/local/lib", "-jar", "/usr/local/lib/simple-java-1.0-SNAPSHOT.jar"]