Skip to content

Commit

Permalink
update collector to build image using ocb
Browse files Browse the repository at this point in the history
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 <alex@boten.ca>
  • Loading branch information
codeboten authored and Alex Boten committed Jul 21, 2023
1 parent 3bcf333 commit 69c199a
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ release.
([#988](https://github.com/open-telemetry/opentelemetry-demo/pull/988))
* [FraudDetectionService] Updated Kotlin version and OTel dependencies
([#987](https://github.com/open-telemetry/opentelemetry-demo/pull/987))
* [otelcol] Use the collector builder to produce otelcol docker image
([#944](https://github.com/open-telemetry/opentelemetry-demo/pull/944))

## 1.4.0

Expand Down
7 changes: 6 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -645,8 +645,13 @@ services:

# OpenTelemetry Collector
otelcol:
image: otel/opentelemetry-collector-contrib:0.76.1
image: ${IMAGE_NAME}:${IMAGE_VERSION}-otelcol
container_name: otel-col
build:
context: ./
dockerfile: ./src/otelcollector/Dockerfile
cache_from:
- ${IMAGE_NAME}:${IMAGE_VERSION}-otelcol
deploy:
resources:
limits:
Expand Down
28 changes: 28 additions & 0 deletions src/otelcollector/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
FROM golang:latest as build

ARG TARGETARCH=arm64
ARG BUILDER_VERSION=0.81.0

RUN curl -L -o /builder https://github.com/open-telemetry/opentelemetry-collector/releases/download/cmd%2Fbuilder%2Fv${BUILDER_VERSION}/ocb_${BUILDER_VERSION}_linux_${TARGETARCH}
RUN chmod +x /builder
WORKDIR /build
COPY ./src/otelcollector/manifest.yml ./
ENV GOARCH=arm64
ENV CGO_ENABLED=0
RUN /builder --config ./manifest.yml --output-path /build/_build
RUN ls /build/_build

FROM alpine:3.16 as certs
RUN apk --update add ca-certificates

FROM alpine

ARG USER_UID=10001
USER ${USER_UID}

COPY --from=certs /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY --from=build --chmod=755 /build/_build/otelcol-demo /otelcol-demo
COPY ./src/otelcollector/otelcol-*.yml /etc/otelcol/
ENTRYPOINT ["/otelcol-demo"]
CMD ["--config", "/etc/otelcol/otelcol-config.yml"]
EXPOSE 4317 4318
24 changes: 24 additions & 0 deletions src/otelcollector/manifest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright The OpenTelemetry Authors
# SPDX-License-Identifier: Apache-2.0

dist:
module: github.com/open-telemetry/opentelemetry-demo/src/otelcollector
name: otelcol-demo
description: OpenTelemetry Collector for OpenTelemetry Demo
version: 0.81.0
output_path: ./_build
otelcol_version: 0.81.0

receivers:
- gomod: go.opentelemetry.io/collector/receiver/otlpreceiver v0.81.0

exporters:
- gomod: go.opentelemetry.io/collector/exporter/loggingexporter v0.81.0
- gomod: go.opentelemetry.io/collector/exporter/otlpexporter v0.81.0
- gomod: go.opentelemetry.io/collector/exporter/otlphttpexporter v0.81.0
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/exporter/prometheusexporter v0.81.0
processors:
- gomod: go.opentelemetry.io/collector/processor/batchprocessor v0.81.0
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/processor/filterprocessor v0.81.0
connectors:
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/connector/spanmetricsconnector v0.81.0

0 comments on commit 69c199a

Please sign in to comment.