A Cloud Foundry buildpack for apps requiring NGINX.
This fork adds the OpenTelemetry nginx plugin.
The libraries are built on an Ubuntu 22.04 VM (after apt-get update && apt-get upgrade to sync to latest libraries):
sudo apt install cmake build-essential autoconf libtool libpcre++-dev libssl-dev zlib1g-dev clang libcurl4-openssl-dev nlohmann-json3-dev nginx git
git clone https://github.com/open-telemetry/opentelemetry-cpp-contrib.git -b webserver/v1.0.3
git clone --shallow-submodules --depth 1 --recurse-submodules -b v1.49.2 https://github.com/grpc/grpc
git clone --shallow-submodules --depth 1 --recurse-submodules -b v1.8.1 https://github.com/open-telemetry/opentelemetry-cpp.git
cd grpc/
mkdir -p cmake/build
cd cmake/build/
cmake -DgRPC_INSTALL=ON -DgRPC_BUILD_TESTS=OFF -DCMAKE_BUILD_TYPE=Release -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 -DCMAKE_CXX_STANDARD=17 ../..
make -j 8
sudo make install
cd ~/
cd opentelemetry-cpp
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DWITH_OTLP=ON -DWITH_OTLP_GRPC=ON -DWITH_OTLP_HTTP=OFF -DBUILD_TESTING=OFF -DWITH_EXAMPLES=OFF -DCMAKE_CXX_STANDARD=17 -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DWITH_ABSEIL=ON ..
make -j 8
sudo make install
cd ~/
cd opentelemetry-cpp-contrib/instrumentation/nginx/
mkdir build
cd build/
cmake -DNGINX_VERSION=1.21.4 -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/share/nginx/modules -DCMAKE_CXX_STANDARD=17 ..
make -j 8
sudo make install
# The "otel_ngx_module.so" is now in the current (build) directory
strip otel_ngx_module.so # the binary is massive (optional)
tar czf otel_ngx_module_nginx1.21.4_5c0cc9c8.tar.gz otel_ngx_module.so
cd ..
# It should be tar-gzipped and copied into the dist folder in the buildpack. The manifest should be updated accordingly
Official buildpack documentation can be found at here.
To use this buildpack, you will need to include an nginx.conf
file in your app. Here's an example.
To build this buildpack, run the following command from the buildpack's directory:
-
Source the .envrc file in the buildpack directory.
source .envrc
To simplify the process in the future, install direnv which will automatically source .envrc when you change directories.
-
Install buildpack-packager
./scripts/install_tools.sh
-
Build the buildpack
buildpack-packager build [ -cached=(true|false) ] -any-stack
-
Use in Cloud Foundry
Upload the buildpack to your Cloud Foundry and optionally specify it by name
cf create-buildpack [BUILDPACK_NAME] [BUILDPACK_ZIP_FILE_PATH] 1 cf push my_app [-b BUILDPACK_NAME]
Buildpacks use the Cutlass framework for running integration tests.
To test this buildpack, run the following command from the buildpack's directory:
-
Source the .envrc file in the buildpack directory.
source .envrc
To simplify the process in the future, install direnv which will automatically source .envrc when you change directories.
-
Run unit tests
./scripts/unit.sh
-
Run integration tests
./scripts/integration.sh
More information can be found on Github cutlass.
Find our guidelines here.
Join the #buildpacks channel in our Slack community
Open an issue on this project
The project backlog is on Pivotal Tracker