Skip to content

Instantly share code, notes, and snippets.

@dgolombek
Created June 2, 2022 13:26
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dgolombek/0800c77d4a4dd17369fba13ae49d2cd2 to your computer and use it in GitHub Desktop.
Save dgolombek/0800c77d4a4dd17369fba13ae49d2cd2 to your computer and use it in GitHub Desktop.
# Stolen from
# https://github.com/nginxinc/nginx-unsupported-modules/blob/master/ngx_otel_module/Dockerfile.base.debian
# plus
# https://github.com/nginxinc/nginx-unsupported-modules/blob/master/ngx_otel_module/Dockerfile.debian
# Updated to build on U18, and had to update the apt-add-repository for cmake to target bionic
# Updated to build DEBUG target for debugging
FROM <local_repo>/ubuntu18:latest
ENV DEBIAN_FRONTEND=noninteractive
ENV GRPC_VERSION_TAG=v1.36.4
ENV OTEL_CPP_VERSION_TAG=v1.4.0
# Can be one of Debug, Release, RelWithDebInfo and MinSizeRel
ENV CMAKE_CONFIG=Debug
RUN set -eux; \
apt-get update -qqq; \
apt-get install --no-install-recommends --no-install-suggests -qqq --yes \
build-essential \
autoconf \
libtool \
pkg-config \
ca-certificates \
gcc \
g++ \
git \
libcurl4-openssl-dev \
libpcre3-dev \
gnupg2 \
lsb-release \
curl \
apt-transport-https \
software-properties-common \
zlib1g-dev; \
mkdir /build; \
curl -o /etc/apt/trusted.gpg.d/kitware.asc https://apt.kitware.com/keys/kitware-archive-latest.asc; \
apt-add-repository "deb https://apt.kitware.com/ubuntu/ bionic main"; \
apt-get update -qqq; \
apt-get install --no-install-recommends --no-install-suggests -qqq --yes cmake; \
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \
rm -rf /var/lib/apt/lists/* /var/tmp/* /tmp/*
RUN set -eux; \
git clone --depth 1 --shallow-submodules --branch ${GRPC_VERSION_TAG} --recurse-submodules https://github.com/grpc/grpc.git /build/grpc; \
cd /build/grpc; \
mkdir build; \
cd build; \
cmake \
-DgRPC_INSTALL=ON \
-DgRPC_BUILD_TESTS=OFF \
-DCMAKE_INSTALL_PREFIX=/install \
-DCMAKE_BUILD_TYPE=${CMAKE_CONFIG} \
-DgRPC_BUILD_GRPC_NODE_PLUGIN=OFF \
-DgRPC_BUILD_GRPC_OBJECTIVE_C_PLUGIN=OFF \
-DgRPC_BUILD_GRPC_PHP_PLUGIN=OFF \
-DgRPC_BUILD_GRPC_PHP_PLUGIN=OFF \
-DgRPC_BUILD_GRPC_PYTHON_PLUGIN=OFF \
-DgRPC_BUILD_GRPC_RUBY_PLUGIN=OFF \
..; \
cmake --build . --config ${CMAKE_CONFIG}; \
cmake --install . --config ${CMAKE_CONFIG}; \
rm -rf /build/grpc
RUN set -eux; \
git clone --depth 1 --shallow-submodules --branch ${OTEL_CPP_VERSION_TAG} --recurse-submodules https://github.com/open-telemetry/opentelemetry-cpp /build/opentelemetry-cpp; \
mkdir /build/opentelemetry-cpp/build; \
cd /build/opentelemetry-cpp/build; \
cmake cmake \
-DCMAKE_BUILD_TYPE=${CMAKE_CONFIG} \
-DCMAKE_INSTALL_PREFIX=/install \
-DCMAKE_PREFIX_PATH=/install \
-DWITH_OTLP=ON \
-DWITH_OTLP_GRPC=ON \
-DWITH_OTLP_HTTP=OFF \
-DBUILD_TESTING=OFF \
-DWITH_EXAMPLES=OFF \
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \
..; \
cmake --build . --config ${CMAKE_CONFIG}; \
cmake --install . --config ${CMAKE_CONFIG}; \
rm -rf /build/opentelemetry-cpp
ARG NGINX_VERSION=1.21.6
ENV NGINX_VERSION=$NGINX_VERSION
ENV OTEL_CPP_CONTRIB_VERSION_TAG=main
# Remove this cachebust if OTEL_CPP_CONTRIB_VERSION_TAG ever changes off `main` to a pinned release
ARG CACHEBUST=1
RUN echo "${CACHEBUST}" # Actually bust the cache, to ensure we pull latest code
RUN git clone --depth 1 --branch ${OTEL_CPP_CONTRIB_VERSION_TAG} https://github.com/open-telemetry/opentelemetry-cpp-contrib.git /build/opentelemetry-cpp-contrib; \
cd /build/opentelemetry-cpp-contrib; \
mkdir instrumentation/nginx/build
WORKDIR /build/opentelemetry-cpp-contrib/instrumentation/nginx
COPY nginx_${NGINX_VERSION}.orig.tar.gz /tmp/nginx.tar.gz
COPY nginx_version.patch .
RUN patch < nginx_version.patch
WORKDIR /build/opentelemetry-cpp-contrib/instrumentation/nginx/build
RUN set -eux; \
cmake \
-DCMAKE_BUILD_TYPE=${CMAKE_CONFIG} \
-DCMAKE_PREFIX_PATH=/install \
-DCMAKE_INSTALL_PREFIX=/nginx-modules \
..; \
mkdir /nginx-modules; \
cmake --build . --config ${CMAKE_CONFIG}; \
cmake --install . --config ${CMAKE_CONFIG}
CMD /bin/bash
exporter = "otlp"
processor = "batch"
[exporters.otlp]
# Alternatively the OTEL_EXPORTER_OTLP_ENDPOINT environment variable can also be used.
host = "localhost"
port = 4317
[processors.batch]
max_queue_size = 2048
schedule_delay_millis = 5000
max_export_batch_size = 512
[service]
name = "proxy" # Opentelemetry resource name
[sampler]
name = "TraceIdRatioBased" # Also: AlwaysOn, AlwaysOff
ratio = 0.1
parent_based = true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment