Skip to content

Commit

Permalink
update collector to build image using ocb (open-telemetry#944)
Browse files Browse the repository at this point in the history
* 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 <alex@boten.ca>

* update build-images

Signed-off-by: Alex Boten <aboten@lightstep.com>

* add license

Signed-off-by: Alex Boten <aboten@lightstep.com>

---------

Signed-off-by: Alex Boten <alex@boten.ca>
Signed-off-by: Alex Boten <aboten@lightstep.com>
Co-authored-by: Austin Parker <austin@ap2.io>
  • Loading branch information
Alex Boten and austinlparker committed Jul 21, 2023
1 parent 31a6160 commit fe591dd
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .github/workflows/build-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ jobs:
- file: ./src/loadgenerator/Dockerfile
tag_suffix: loadgenerator
context: ./
- file: ./src/otelcollector/Dockerfile
tag_suffix: otelcollector
context: ./
- file: ./src/paymentservice/Dockerfile
tag_suffix: paymentservice
context: ./
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,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
31 changes: 31 additions & 0 deletions src/otelcollector/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Copyright The OpenTelemetry Authors
# SPDX-License-Identifier: Apache-2.0

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 fe591dd

Please sign in to comment.