Skip to content

Commit

Permalink
feat: bump agent + readme
Browse files Browse the repository at this point in the history
  • Loading branch information
jacopocarlini committed Oct 10, 2024
1 parent 25cce40 commit 3f6cebd
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ RUN addgroup spring && useradd -g spring spring
USER spring:spring

# https://github.com/microsoft/ApplicationInsights-Java/releases
ADD --chown=spring:spring https://github.com/microsoft/ApplicationInsights-Java/releases/download/3.4.19/applicationinsights-agent-3.4.19.jar /applicationinsights-agent.jar
ADD --chown=spring:spring https://github.com/microsoft/ApplicationInsights-Java/releases/download/3.6.0/applicationinsights-agent-3.6.0.jar /applicationinsights-agent.jar

COPY --chown=spring:spring docker/applicationinsights.json ./applicationinsights.json

Expand Down
51 changes: 51 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,52 @@
# docker-base-template based on Java 17
This image is based on `eclipse-temurin:17-jre` with applicationinsights agent v3.6.0.

It is useful to run a SpringBoot application v2/v3.

## How to use
``` Dockerfile
#
# Build
#
FROM maven:3.9.3-amazoncorretto-17@sha256:4ab7db7bd5f95e58b0ba1346ff29d6abdd9b73e5fd89c5140edead8b037386ff AS buildtime
WORKDIR /build
COPY . .
RUN mvn clean package -Dmaven.test.skip=true

#
# Package stage
#
FROM --platform=linux/amd64 amazoncorretto:17.0.9-alpine3.18@sha256:df48bf2e183230040890460ddb4359a10aa6c7aad24bd88899482c52053c7e17 as builder
COPY --from=buildtime /build/target/*.jar application.jar
RUN java -Djarmode=layertools -jar application.jar extract

#
# Run
#
FROM ghcr.io/pagopa/docker-base-springboot-openjdk17:v2.1.2@sha256:824a241756a32ac9eeef4585a3a266fb019d2c599337269b0c8b419de4c2df3e

COPY --chown=spring:spring --from=builder dependencies/ ./
COPY --chown=spring:spring --from=builder snapshot-dependencies/ ./

# https://github.com/moby/moby/issues/37965#issuecomment-426853382
RUN true
COPY --chown=spring:spring --from=builder spring-boot-loader/ ./
COPY --chown=spring:spring --from=builder application/ ./
```


## Application Insights Agent
The agent uses the configuration `/docker/applicationinsights.json`.
By default, the sampling is enabled
- dependency: 5%
- trace: 5%
- exception: 100%
- request: 100%

If you want to customize the agent you can add your file in the `Dockerimage`

``` Dockerfile
FROM ghcr.io/pagopa/docker-base-springboot-openjdk17:v2.1.2@sha256:824a241756a32ac9eeef4585a3a266fb019d2c599337269b0c8b419de4c2df3e
COPY --chown=spring:spring your/path/to/applicationinsights.json ./applicationinsights.json
```

34 changes: 19 additions & 15 deletions docker/applicationinsights.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,24 @@
"level": "INFO"
},
"sampling": {
"percentage": 5
},
"preview": {
"sampling": {
"overrides": [
{
"telemetryType": "exception",
"percentage": 100
},
{
"telemetryType": "request",
"percentage": 100
}
]
}
"percentage": 5,
"overrides": [
{
"telemetryType": "dependency",
"percentage": 5
},
{
"telemetryType": "trace",
"percentage": 5
},
{
"telemetryType": "exception",
"percentage": 100
},
{
"telemetryType": "request",
"percentage": 100
}
]
}
}

0 comments on commit 3f6cebd

Please sign in to comment.