Skip to content

Commit

Permalink
Include smart agent bundle in docker image (#241)
Browse files Browse the repository at this point in the history
  • Loading branch information
bjsignalfx authored Apr 12, 2021
1 parent e579e2e commit 3723423
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ delete-tag:
docker-otelcol:
GOOS=linux $(MAKE) otelcol
cp ./bin/otelcol_linux_amd64 ./cmd/otelcol/otelcol
docker build -t otelcol ./cmd/otelcol/
docker build -t otelcol --build-arg SMART_AGENT_RELEASE=$(SMART_AGENT_RELEASE) ./cmd/otelcol/
rm ./cmd/otelcol/otelcol

.PHONY: binaries-all-sys
Expand Down
27 changes: 24 additions & 3 deletions cmd/otelcol/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,37 @@
FROM alpine:3.12 as certs
ARG SMART_AGENT_RELEASE=v5.9.1
ARG ALPINE_VERSION=3.12

FROM alpine:${ALPINE_VERSION} as certs
RUN apk --update add ca-certificates

FROM alpine:3.12 AS otelcol
FROM alpine:${ALPINE_VERSION} AS otelcol
COPY otelcol /
# Note that this shouldn't be necessary, but in some cases the file seems to be
# copied with the execute bit lost (see #1317)
RUN chmod 755 /otelcol

FROM alpine:${ALPINE_VERSION} AS smartagent
ARG SMART_AGENT_RELEASE
RUN mkdir -p "$(dirname "/usr/lib/splunk-otel-collector/agent-bundle")" && \
SMART_AGENT=signalfx-agent-${SMART_AGENT_RELEASE#v}.tar.gz && \
URL=https://github.com/signalfx/signalfx-agent/releases/download/${SMART_AGENT_RELEASE}/$SMART_AGENT && \
wget "$URL" && tar -xzf $SMART_AGENT && mv signalfx-agent /usr/lib/splunk-otel-collector/agent-bundle && \
# Absolute path of interpreter in smart agent dir is set in dependent binaries
# requiring the interpreter location not to change.
/usr/lib/splunk-otel-collector/agent-bundle/bin/patch-interpreter /usr/lib/splunk-otel-collector/agent-bundle && \
rm -f /usr/lib/splunk-otel-collector/agent-bundle/bin/signalfx-agent \
/usr/lib/splunk-otel-collector/agent-bundle/bin/agent-status \
$SMART_AGENT

FROM scratch
ENV SPLUNK_BUNDLE_DIR=/usr/lib/splunk-otel-collector/agent-bundle
ENV SPLUNK_COLLECTD_DIR=$SIGNALFX_BUNDLE_DIR/run/collectd
COPY --from=certs /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY --from=otelcol /otelcol /
COPY config/collector/gateway_config.yaml /etc/otel/collector/gateway_config.yaml
# Maintaining interpreter location as required.
COPY --from=smartagent /usr/lib/splunk-otel-collector/agent-bundle /usr/lib/splunk-otel-collector/agent-bundle
COPY config/collector/gateway_config.yaml /etc/otel/collector/gateway_config.yaml
COPY config/collector/otlp_config_linux.yaml /etc/otel/collector/otlp_config_linux.yaml
COPY config/collector/agent_config.yaml /etc/otel/collector/agent_config.yaml
ENTRYPOINT ["/otelcol"]
EXPOSE 13133 14250 14268 55680 4317 6060 7276 8888 9411 9443

0 comments on commit 3723423

Please sign in to comment.