Skip to content

Commit 83bd7c7

Browse files
Alex Botenaustinlparker
authored andcommitted
update collector to build image using ocb (open-telemetry#944)
* update collector to build image using ocb The collector in this repository now uses the otel collector builder to build a custom binary which it embeds in a docker container for the demo. Still to do: - [ ] update curl command to pull builder for specific architectures - [ ] allow passing the version of the builder to use Signed-off-by: Alex Boten <[email protected]> * update build-images Signed-off-by: Alex Boten <[email protected]> * add license Signed-off-by: Alex Boten <[email protected]> --------- Signed-off-by: Alex Boten <[email protected]> Signed-off-by: Alex Boten <[email protected]> Co-authored-by: Austin Parker <[email protected]>
1 parent 2efc46d commit 83bd7c7

File tree

5 files changed

+66
-1
lines changed

5 files changed

+66
-1
lines changed

.github/workflows/build-images.yml

+3
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ jobs:
5858
- file: ./src/loadgenerator/Dockerfile
5959
tag_suffix: loadgenerator
6060
context: ./
61+
- file: ./src/otelcollector/Dockerfile
62+
tag_suffix: otelcollector
63+
context: ./
6164
- file: ./src/paymentservice/Dockerfile
6265
tag_suffix: paymentservice
6366
context: ./

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ release.
6363
([#988](https://github.com/open-telemetry/opentelemetry-demo/pull/988))
6464
* [FraudDetectionService] Updated Kotlin version and OTel dependencies
6565
([#987](https://github.com/open-telemetry/opentelemetry-demo/pull/987))
66+
* [otelcol] Use the collector builder to produce otelcol docker image
67+
([#944](https://github.com/open-telemetry/opentelemetry-demo/pull/944))
6668

6769
## 1.4.0
6870

docker-compose.yml

+6-1
Original file line numberDiff line numberDiff line change
@@ -645,8 +645,13 @@ services:
645645

646646
# OpenTelemetry Collector
647647
otelcol:
648-
image: otel/opentelemetry-collector-contrib:0.76.1
648+
image: ${IMAGE_NAME}:${IMAGE_VERSION}-otelcol
649649
container_name: otel-col
650+
build:
651+
context: ./
652+
dockerfile: ./src/otelcollector/Dockerfile
653+
cache_from:
654+
- ${IMAGE_NAME}:${IMAGE_VERSION}-otelcol
650655
deploy:
651656
resources:
652657
limits:

src/otelcollector/Dockerfile

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Copyright The OpenTelemetry Authors
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
FROM golang:latest as build
5+
6+
ARG TARGETARCH=arm64
7+
ARG BUILDER_VERSION=0.81.0
8+
9+
RUN curl -L -o /builder https://github.com/open-telemetry/opentelemetry-collector/releases/download/cmd%2Fbuilder%2Fv${BUILDER_VERSION}/ocb_${BUILDER_VERSION}_linux_${TARGETARCH}
10+
RUN chmod +x /builder
11+
WORKDIR /build
12+
COPY ./src/otelcollector/manifest.yml ./
13+
ENV GOARCH=arm64
14+
ENV CGO_ENABLED=0
15+
RUN /builder --config ./manifest.yml --output-path /build/_build
16+
RUN ls /build/_build
17+
18+
FROM alpine:3.16 as certs
19+
RUN apk --update add ca-certificates
20+
21+
FROM alpine
22+
23+
ARG USER_UID=10001
24+
USER ${USER_UID}
25+
26+
COPY --from=certs /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
27+
COPY --from=build --chmod=755 /build/_build/otelcol-demo /otelcol-demo
28+
COPY ./src/otelcollector/otelcol-*.yml /etc/otelcol/
29+
ENTRYPOINT ["/otelcol-demo"]
30+
CMD ["--config", "/etc/otelcol/otelcol-config.yml"]
31+
EXPOSE 4317 4318

src/otelcollector/manifest.yml

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Copyright The OpenTelemetry Authors
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
dist:
5+
module: github.com/open-telemetry/opentelemetry-demo/src/otelcollector
6+
name: otelcol-demo
7+
description: OpenTelemetry Collector for OpenTelemetry Demo
8+
version: 0.81.0
9+
output_path: ./_build
10+
otelcol_version: 0.81.0
11+
12+
receivers:
13+
- gomod: go.opentelemetry.io/collector/receiver/otlpreceiver v0.81.0
14+
15+
exporters:
16+
- gomod: go.opentelemetry.io/collector/exporter/loggingexporter v0.81.0
17+
- gomod: go.opentelemetry.io/collector/exporter/otlpexporter v0.81.0
18+
- gomod: go.opentelemetry.io/collector/exporter/otlphttpexporter v0.81.0
19+
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/exporter/prometheusexporter v0.81.0
20+
processors:
21+
- gomod: go.opentelemetry.io/collector/processor/batchprocessor v0.81.0
22+
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/processor/filterprocessor v0.81.0
23+
connectors:
24+
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/connector/spanmetricsconnector v0.81.0

0 commit comments

Comments
 (0)