/
Dockerfile.production
47 lines (38 loc) · 2.47 KB
/
Dockerfile.production
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# Example production Dockerfile:
# - Spring petclinic: https://github.com/spring-projects/spring-petclinic
# - Grafana Agent OR OpenTelemetry Collector
FROM springio/petclinic
# 1. Install the Grafana Agent or OpenTelemetry Collector:
# - Grafana Agent: https://github.com/grafana/grafana-opentelemetry-java#grafana-agent
# - OR OpenTelemetry Collector: https://github.com/grafana/grafana-opentelemetry-java#opentelemetry-collector
# 2. If the Grafana Agent or OpenTelemetry Collector is running on a different host, set the URL:
ENV OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317
# 3. If the Grafana Agent or OpenTelemetry Collector does not offer gRPC, set the protocol to "http/protobuf":
ENV OTEL_EXPORTER_OTLP_PROTOCOL=grpc
# 4. Choose a **Service Name** to identify the service (e.g. `cart`)
ENV OTEL_SERVICE_NAME=<Service Name>
# 4. Add attributes to filter data (recommended):
# - **deployment.environment**: Name of the deployment environment (`staging` or `production`)
# - **service.namespace**: A namespace to group similar services
# (e.g. `shop` would create `shop/cart` in Application Observability)
# - **service.version**: The application version, to see if a new version has introduced a bug
# - **service.instance.id**: The unique instance, for example the Pod name (a UUID is generated by default)
ENV OTEL_RESOURCE_ATTRIBUTES=deployment.environment=<Environment>,service.namespace=<Namespace>,service.version=<Version>
# Build and run the application:
# 5. docker build -t grafana_opentelemetry_java_demo .
# 6. docker run -p 8080:8080 grafana_opentelemetry_java_demo
# 7. Open <http://localhost:8080> in your browser
# 8. Click on "Error" in the top right corner to generate an error
# 9. Open Application Observability in Grafana Cloud:
# - Click on the menu icon in the top left corner
# - Open the "Observability" menu
# - Click on "Application"
# Note: It might take up to five minutes for data to appear.
ARG version=2.3.0-beta.1
WORKDIR /app/
# use a fixed version
# ADD https://github.com/grafana/grafana-opentelemetry-java/releases/download/v$version/grafana-opentelemetry-java.jar /app/grafana-opentelemetry-java.jar
# use the latest version
# user is changed, because the springio/petclinic image is running as cnb
ADD --chown=cnb https://github.com/grafana/grafana-opentelemetry-java/releases/latest/download/grafana-opentelemetry-java.jar /app/grafana-opentelemetry-java.jar
ENV JAVA_TOOL_OPTIONS=-javaagent:/app/grafana-opentelemetry-java.jar