From f7e0a2832438bd1f8cb7ebc4cd2a13c134617ee0 Mon Sep 17 00:00:00 2001 From: Trevor Dearham Date: Mon, 18 Mar 2024 13:01:13 +0000 Subject: [PATCH 1/2] otel-webserver support for arm64 --- .github/workflows/webserver.yml | 195 +++++++++++++++--- .../otel-webserver-module/Dockerfile | 34 +-- .../otel-webserver-module/build.gradle | 9 +- .../otel-webserver-module/common.gradle | 5 + .../otel-webserver-module/docker-compose.yml | 18 ++ .../docker/centos7/Dockerfile | 40 ++-- .../docker/ubuntu20.04/Dockerfile | 2 +- .../test/ApacheTesting.sh | 3 +- .../test/NginxTesting.sh | 4 +- .../test/unit/ApiUtils_test.cpp | 2 +- 10 files changed, 247 insertions(+), 65 deletions(-) diff --git a/.github/workflows/webserver.yml b/.github/workflows/webserver.yml index 30056d472..1cc8c5a55 100644 --- a/.github/workflows/webserver.yml +++ b/.github/workflows/webserver.yml @@ -13,8 +13,8 @@ on: - '.github/workflows/webserver.yml' jobs: - webserver-build-test-ubuntu: - name: webserver-ubuntu-build + webserver-build-test-ubuntu-x64: + name: webserver-ubuntu-build-x64 runs-on: ubuntu-20.04 steps: - name: checkout otel webserver @@ -24,6 +24,7 @@ jobs: uses: docker/setup-buildx-action@master with: install: true + platforms: linux/amd64 - name: cache docker layers uses: actions/cache@v3 with: @@ -34,18 +35,18 @@ jobs: - name: setup docker image run: | cd instrumentation/otel-webserver-module - docker buildx build -t apache_ubuntu -f docker/ubuntu20.04/Dockerfile \ - --cache-from type=local,src=/tmp/buildx-cache/apache_ubuntu \ - --cache-to type=local,dest=/tmp/buildx-cache/apache_ubuntu-new \ + docker buildx build -t apache_ubuntu_amd64 -f docker/ubuntu20.04/Dockerfile \ + --cache-from type=local,src=/tmp/buildx-cache/apache_ubuntu_amd64 \ + --cache-to type=local,dest=/tmp/buildx-cache/apache_ubuntu_amd64-new \ --load . - name: build run: | - docker run -idt --name apache_ubuntu_container apache_ubuntu /bin/bash + docker run -idt --name apache_ubuntu_container_amd64 apache_ubuntu_amd64 /bin/bash cd instrumentation/otel-webserver-module - docker exec apache_ubuntu_container bash -c \ + docker exec apache_ubuntu_container_amd64 bash -c \ 'cd /otel-webserver-module; rm -rf *;' - docker cp . $(docker inspect --format="{{.Id}}" apache_ubuntu_container):/otel-webserver-module/ - docker exec apache_ubuntu_container bash -c \ + docker cp . $(docker inspect --format="{{.Id}}" apache_ubuntu_container_amd64):/otel-webserver-module/ + docker exec apache_ubuntu_container_amd64 bash -c \ 'cd /otel-webserver-module; rm -rf build; \ cp -r /dependencies /otel-webserver-module/; \ cp -r /build-dependencies /otel-webserver-module/; \ @@ -54,20 +55,91 @@ jobs: - name: update cache run: | - rm -rf /tmp/buildx-cache/apache_ubuntu - mv /tmp/buildx-cache/apache_ubuntu-new /tmp/buildx-cache/apache_ubuntu + rm -rf /tmp/buildx-cache/apache_ubuntu_amd64 + mv /tmp/buildx-cache/apache_ubuntu_amd64-new /tmp/buildx-cache/apache_ubuntu_amd64 - webserver-build-test-centos7: - name: webserver-centos7-build + webserver-build-test-ubuntu-arm64: + name: webserver-ubuntu-build-arm64 runs-on: ubuntu-20.04 steps: - name: checkout otel webserver uses: actions/checkout@v3 + - name: setup qemu + uses: docker/setup-qemu-action@master - name: setup buildx id: buildx uses: docker/setup-buildx-action@master with: install: true + platforms: linux/arm64 + - name: cache docker layers + uses: actions/cache@v3 + with: + path: /tmp/buildx-cache/ + key: apache-ubuntu-20.04-${{ github.sha }} + restore-keys: | + apache-ubuntu-20.04 + - name: setup docker image + run: | + cd instrumentation/otel-webserver-module + docker buildx build -t apache_ubuntu_arm64 -f docker/ubuntu20.04/Dockerfile \ + --cache-from type=local,src=/tmp/buildx-cache/apache_ubuntu_arm64 \ + --cache-to type=local,dest=/tmp/buildx-cache/apache_ubuntu_arm64-new \ + --load . --platform linux/arm64 + - name: build + run: | + docker run -idt --platform linux/arm64 --name apache_ubuntu_container_arm64 apache_ubuntu_arm64 /bin/bash + cd instrumentation/otel-webserver-module + docker exec apache_ubuntu_container_arm64 bash -c \ + 'cd /otel-webserver-module; rm -rf *;' + docker cp . $(docker inspect --format="{{.Id}}" apache_ubuntu_container_arm64):/otel-webserver-module/ + docker exec apache_ubuntu_container_arm64 bash -c \ + 'cd /otel-webserver-module; rm -rf build; \ + cp -r /dependencies /otel-webserver-module/; \ + cp -r /build-dependencies /otel-webserver-module/; \ + + ./gradlew assembleWebServerModule -DtargetSystem=ubuntu' + # - name: unit test + # run: | + # docker exec apache_ubuntu_container_arm64 bash -c \ + # 'cd /otel-webserver-module; ./gradlew runUnitTest' + - name: update cache + run: | + rm -rf /tmp/buildx-cache/apache_ubuntu_arm64 + mv /tmp/buildx-cache/apache_ubuntu_arm64-new /tmp/buildx-cache/apache_ubuntu_arm64 + # - name: copy artifacts + # id: artifacts + # run: | + # cd instrumentation/otel-webserver-module + # mkdir -p /tmp/apache_ubuntu_arm64/ + # docker cp apache_ubuntu_container_arm64:/otel-webserver-module/build/opentelemetry-webserver-sdk-arm64-linux.tgz \ + # /tmp/apache_ubuntu_arm64/ + # - name: upload artifacts + # uses: actions/upload-artifact@v3 + # with: + # name: opentelemetry-webserver-sdk-arm64-linux.tgz + # path: /tmp/apache_ubuntu_arm64/opentelemetry-webserver-sdk-arm64-linux.tgz + # - name: run integrationtest + # run: | + # docker rm -f apache_ubuntu_container_arm64 + # cd instrumentation/otel-webserver-module + # docker compose --profile ubuntu20.04 up -d + # docker ps -a + # sleep 30 + # ./gradlew :test:integration:integrationTests -i + + webserver-build-test-centos7-x64: + name: webserver-centos7-build-x64 + runs-on: ubuntu-20.04 + steps: + - name: checkout otel webserver + uses: actions/checkout@v3 + - name: setup buildx + id: buildx + uses: docker/setup-buildx-action@master + with: + install: true + platforms: linux/amd64 # - name: cache docker layers # uses: actions/cache@v3 # with: @@ -78,45 +150,114 @@ jobs: - name: setup docker image run: | cd instrumentation/otel-webserver-module - docker buildx build -t apache_centos7 -f docker/centos7/Dockerfile \ + docker buildx build -t apache_centos7_amd64 -f docker/centos7/Dockerfile \ --load . - name: build run: | - docker run -idt --name apache_centos7_container apache_centos7 /bin/bash + docker run -idt --name apache_centos7_container_amd64 apache_centos7_amd64 /bin/bash cd instrumentation/otel-webserver-module - docker exec apache_centos7_container bash -c \ + docker exec apache_centos7_container_amd64 bash -c \ 'cd /otel-webserver-module; rm -rf *;' - docker cp . $(docker inspect --format="{{.Id}}" apache_centos7_container):/otel-webserver-module/ - docker exec apache_centos7_container bash -c \ + docker cp . $(docker inspect --format="{{.Id}}" apache_centos7_container_amd64):/otel-webserver-module/ + docker exec apache_centos7_container_amd64 bash -c \ 'cd /otel-webserver-module; rm -rf build; \ cp -r /dependencies /otel-webserver-module/; \ cp -r /build-dependencies /otel-webserver-module/; \ ./gradlew assembleWebServerModule' - name: unit test run: | - docker exec apache_centos7_container bash -c \ + docker exec apache_centos7_container_amd64 bash -c \ 'cd /otel-webserver-module; ./gradlew runUnitTest' # - name: update cache # run: | - # rm -rf /tmp/buildx-cache/apache_centos7 - # mv /tmp/buildx-cache/apache_centos7-new /tmp/buildx-cache/apache_centos7 + # rm -rf /tmp/buildx-cache/apache_centos7_amd64 + # mv /tmp/buildx-cache/apache_centos7_amd64-new /tmp/buildx-cache/apache_centos7_amd64 - name: copy artifacts id: artifacts run: | cd instrumentation/otel-webserver-module - mkdir -p /tmp/apache_centos7/ - docker cp apache_centos7_container:/otel-webserver-module/build/opentelemetry-webserver-sdk-x64-linux.tgz \ - /tmp/apache_centos7/ + mkdir -p /tmp/apache_centos7_amd64/ + docker cp apache_centos7_container_amd64:/otel-webserver-module/build/opentelemetry-webserver-sdk-x64-linux.tgz \ + /tmp/apache_centos7_amd64/ - name: upload artifacts uses: actions/upload-artifact@v3 with: name: opentelemetry-webserver-sdk-x64-linux.tgz - path: /tmp/apache_centos7/opentelemetry-webserver-sdk-x64-linux.tgz + path: /tmp/apache_centos7_amd64/opentelemetry-webserver-sdk-x64-linux.tgz + - name: run integrationtest + run: | + docker rm -f apache_centos7_container_amd64 + cd instrumentation/otel-webserver-module + docker compose --profile centos7 up -d + docker ps -a + sleep 30 + ./gradlew :test:integration:integrationTests -i + + webserver-build-test-centos7-arm64: + name: webserver-centos7-build-arm64 + runs-on: ubuntu-20.04 + steps: + - name: checkout otel webserver + uses: actions/checkout@v3 + - name: setup qemu + uses: docker/setup-qemu-action@master + - name: setup buildx + id: buildx + uses: docker/setup-buildx-action@master + with: + install: true + platforms: linux/arm64 + # - name: cache docker layers + # uses: actions/cache@v3 + # with: + # path: /tmp/buildx-cache/ + # key: apache-centos7-${{ github.sha }} + # restore-keys: | + # apache-centos7 + - name: setup docker image + run: | + cd instrumentation/otel-webserver-module + docker buildx build -t apache_centos7_arm64 -f docker/centos7/Dockerfile \ + --load . --platform linux/arm64 --build-arg BUILD_ARCH='arm64' \ + --build-arg CMAKE_ARCH='aarch64' --build-arg GOSU_ARCH='arm64' \ + --build-arg JDK_ARCH='aarch64' --build-arg NGINX_ARCH='aarch64' + - name: build + run: | + docker run -idt --platform linux/arm64 --name apache_centos7_container_arm64 apache_centos7_arm64 /bin/bash + cd instrumentation/otel-webserver-module + docker exec apache_centos7_container_arm64 bash -c \ + 'cd /otel-webserver-module; rm -rf *;' + docker cp . $(docker inspect --format="{{.Id}}" apache_centos7_container_arm64):/otel-webserver-module/ + docker exec apache_centos7_container_arm64 bash -c \ + 'cd /otel-webserver-module; rm -rf build; \ + cp -r /dependencies /otel-webserver-module/; \ + cp -r /build-dependencies /otel-webserver-module/; \ + ./gradlew assembleWebServerModule' + - name: unit test + run: | + docker exec apache_centos7_container_arm64 bash -c \ + 'cd /otel-webserver-module; ./gradlew runUnitTest' + # - name: update cache + # run: | + # rm -rf /tmp/buildx-cache/apache_centos7_arm64 + # mv /tmp/buildx-cache/apache_centos7_arm64-new /tmp/buildx-cache/apache_centos7_arm64 + - name: copy artifacts + id: artifacts + run: | + cd instrumentation/otel-webserver-module + mkdir -p /tmp/apache_centos7_arm64/ + docker cp apache_centos7_container_arm64:/otel-webserver-module/build/opentelemetry-webserver-sdk-arm64-linux.tgz \ + /tmp/apache_centos7_arm64/ + - name: upload artifacts + uses: actions/upload-artifact@v3 + with: + name: opentelemetry-webserver-sdk-arm64-linux.tgz + path: /tmp/apache_centos7_arm64/opentelemetry-webserver-sdk-arm64-linux.tgz - name: run integrationtest run: | - docker rm -f apache_centos7_container + docker rm -f apache_centos7_container_arm64 cd instrumentation/otel-webserver-module - docker-compose --profile centos7 up -d + docker compose --profile centos7 up -d docker ps -a sleep 30 ./gradlew :test:integration:integrationTests -i diff --git a/instrumentation/otel-webserver-module/Dockerfile b/instrumentation/otel-webserver-module/Dockerfile index 6deb7207a..7979a74e1 100644 --- a/instrumentation/otel-webserver-module/Dockerfile +++ b/instrumentation/otel-webserver-module/Dockerfile @@ -1,13 +1,17 @@ FROM centos:6.9 ARG BUILD_NUMBER +ARG BUILD_ARCH='x64' -LABEL NAME=apm/build-image-webserver-agent-centos6-x64 VERSION=$BUILD_NUMBER +LABEL NAME=apm/build-image-webserver-agent-centos6-${BUILD_ARCH} VERSION=$BUILD_NUMBER -ENV GOSU_ARCH amd64 -ENV JDK_ARCH x64 +ARG GOSU_ARCH='amd64' +ENV GOSU_ARCH=${GOSU_ARCH} +ARG JDK_ARCH='x64' +ENV JDK_ARCH=${JDK_ARCH} -ARG PYTHON_VERSION="2.7.8" +ARG PYTHON_VERSION="2.7.18" +ARG CMAKE_ARCH='x86_64' ARG CMAKE_VERSION="3.20" ARG CMAKE_0VERSION="3.20.0" ARG GRPC_VERSION="1.36.4" @@ -18,12 +22,14 @@ ARG APR_VERSION="1.7.0" ARG EXPAT_VERSION="2.3.0" ARG EXPAT_RVERSION="R_2_3_0" ARG APRUTIL_VERSION="1.6.1" +ARG AUTOCONF_BUILD_TYPE='x86_64-unknown-linux-gnu' ARG AUTOCONF_VERSION="2.68" ARG LIBTOOL_VERSION="2.4.6" ARG LOG4CXX_VERSION="0.11.0" ARG GTEST_VERSION="1.10.0" ARG AUTOMAKE_VERSION="1.16.3" ARG PCRE_VERSION="8.44" +ARG NGINX_ARCH='x86_64' ARG NGINX_VERSION="1.26.0" @@ -73,9 +79,9 @@ RUN wget http://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERS && rm -rf Python-${PYTHON_VERSION}.tar.xz && rm -rf Python-${PYTHON_VERSION}.tar # install gosu for easy step-down from root (from https://github.com/tianon/gosu/blob/master/INSTALL.md#from-centos) -ENV GOSU_VERSION=1.10 +ENV GOSU_VERSION=1.11 -RUN curl -o /usr/bin/gosu -SL "https://github.com/tianon/gosu/releases/download/${GOSU_VERSION}/gosu-amd64" \ +RUN curl -o /usr/bin/gosu -SL "https://github.com/tianon/gosu/releases/download/${GOSU_VERSION}/gosu-${GOSU_ARCH}" \ && chmod +x /usr/bin/gosu \ # Verify that the binary works && gosu nobody true @@ -85,11 +91,11 @@ RUN yum install git -y \ && yum clean all # install cmake -RUN wget https://cmake.org/files/v${CMAKE_VERSION}/cmake-${CMAKE_0VERSION}-linux-x86_64.tar.gz \ - && tar -xvf cmake-${CMAKE_0VERSION}-linux-x86_64.tar.gz \ - && cd cmake-${CMAKE_0VERSION}-linux-x86_64 \ +RUN wget https://cmake.org/files/v${CMAKE_VERSION}/cmake-${CMAKE_0VERSION}-linux-${CMAKE_ARCH}.tar.gz \ + && tar -xvf cmake-${CMAKE_0VERSION}-linux-${CMAKE_ARCH}.tar.gz \ + && cd cmake-${CMAKE_0VERSION}-linux-${CMAKE_ARCH} \ && cp -rf * /usr/local/ \ - && cd .. && rm -rf cmake-${CMAKE_0VERSION}-linux-x86_64.tar.gz + && cd .. && rm -rf cmake-${CMAKE_0VERSION}-linux-${CMAKE_ARCH}.tar.gz # install grpc. If planning to upgrade, make sure sed command works RUN git clone https://github.com/grpc/grpc \ @@ -152,7 +158,7 @@ RUN yum install m4 -y RUN wget --no-check-certificate https://ftp.gnu.org/gnu/autoconf/autoconf-${AUTOCONF_VERSION}.tar.gz \ && tar xzf autoconf-${AUTOCONF_VERSION}.tar.gz \ && cd autoconf-${AUTOCONF_VERSION} \ - && ./configure --prefix=/usr/ && make -j && make install && autoconf -V \ + && ./configure --prefix=/usr/ --build=${AUTOCONF_BUILD_TYPE} && make -j && make install && autoconf -V \ && cd .. && rm -rf autoconf-${AUTOCONF_VERSION}.tar.gz # install automake @@ -257,13 +263,13 @@ RUN cp -r /dependencies /otel-webserver-module/ \ RUN echo '[nginx]' >> /etc/yum.repos.d/nginx.repo \ && echo 'name=nginx repo' >> /etc/yum.repos.d/nginx.repo \ - && echo 'baseurl=https://nginx.org/packages/centos/6/x86_64' >> /etc/yum.repos.d/nginx.repo \ + && echo "baseurl=https://nginx.org/packages/centos/6/${NGINX_ARCH}" >> /etc/yum.repos.d/nginx.repo \ && echo 'gpgcheck=0' >> /etc/yum.repos.d/nginx.repo \ && echo 'enabled=1' >> /etc/yum.repos.d/nginx.repo \ && yum install nginx -y RUN cd /otel-webserver-module/build \ - && tar -xf opentelemetry-webserver-sdk-x64-linux.tgz \ + && tar -xf opentelemetry-webserver-sdk-${BUILD_ARCH}-linux.tgz \ && mv -f opentelemetry-webserver-sdk /opt/ \ && cd ../ \ && cp opentelemetry_module.conf /etc/httpd/conf/ \ @@ -278,7 +284,7 @@ RUN cp /otel-webserver-module/conf/nginx/opentelemetry_module.conf /opt/ \ && cd / # Remove unwanted files -RUN rm -rf grpc && rm -rf autoconf-${AUTOCONF_VERSION} && rm -rf automake-${AUTOMAKE_VERSION} && rm -rf cmake-${CMAKE_VERSION}-linux-x86_64 \ +RUN rm -rf grpc && rm -rf autoconf-${AUTOCONF_VERSION} && rm -rf automake-${AUTOMAKE_VERSION} && rm -rf cmake-${CMAKE_VERSION}-linux-${CMAKE_ARCH} \ && rm -rf libtool-${LIBTOOL_VERSION} && rm -rf Python-${PYTHON_VERSION} \ && rm -f apr-${APR_VERSION}.tar.gz && rm -f apr-util-${APRUTIL_VERSION}.tar.gz \ && rm -f httpd-2.2.31.tar.gz && rm -f httpd-2.4.23.tar.gz diff --git a/instrumentation/otel-webserver-module/build.gradle b/instrumentation/otel-webserver-module/build.gradle index 5f8ea4a41..61c232a34 100644 --- a/instrumentation/otel-webserver-module/build.gradle +++ b/instrumentation/otel-webserver-module/build.gradle @@ -23,7 +23,7 @@ project.ext { ansdkOsName = osName ansdkArch = (osArch == 'x86' ? 'i686' : osArch) - gccArchFlag = (osArch == 'x86' ? '-m32' : '-m64') + gccArchFlag = (osArch == 'x86' ? '-m32' : (osArch == 'arm64' ? '-march=armv8-a' : '-m64')) headSHA1 = "" try { @@ -499,7 +499,7 @@ task gypUnitTest(type: Exec) { ANSDK_DIR: modDepDir, BOOST_LIB: BOOST_LIB, BOOST_INCLUDE: BOOST_INCLUDE, - GTEST_LIB_DIR: target_system == "ubuntu" ? + GTEST_LIB_DIR: target_system == "ubuntu" || osArch == "arm64" ? "${modDepDir}/googletest/1.10.0/lib" : "${modDepDir}/googletest/1.10.0/lib64", LIBRARY_FLAGS: libraryFlags, CPP_SDK_VERSION: cppSDKVersion, @@ -536,7 +536,7 @@ task runApacheServer(type: Exec) { dependsOn assembleApacheModule workingDir 'test' - commandLine './ApacheTesting.sh', "${target_system}" + commandLine './ApacheTesting.sh', "${target_system}", "${osArch}" } // Code Coverage @@ -602,6 +602,9 @@ model { release } platforms { + arm { + architecture "arm64" + } x86 { architecture "x86" } diff --git a/instrumentation/otel-webserver-module/common.gradle b/instrumentation/otel-webserver-module/common.gradle index cc5707768..da9323c61 100644 --- a/instrumentation/otel-webserver-module/common.gradle +++ b/instrumentation/otel-webserver-module/common.gradle @@ -8,6 +8,9 @@ defaultTasks 'build' ext { ARCH = '' switch (System.properties['os.arch'].toLowerCase()) { + case "aarch64": + ARCH = "arm64" + break case "amd64": case "x86_64": ARCH = "x64" @@ -42,6 +45,8 @@ ext { osArch = 'x86' } else if (osArch == 'x86_64' || osArch == 'amd64') { osArch = 'x64' + } else if (osArch == 'aarch64') { + osArch = 'arm64' } BUILD_SHA1 = System.getenv('BUILD_SHA') diff --git a/instrumentation/otel-webserver-module/docker-compose.yml b/instrumentation/otel-webserver-module/docker-compose.yml index 6c35ac6ac..c95d26e5f 100644 --- a/instrumentation/otel-webserver-module/docker-compose.yml +++ b/instrumentation/otel-webserver-module/docker-compose.yml @@ -7,6 +7,9 @@ services: build: context: . dockerfile: Dockerfile + platforms: + - "linux/amd64" + - "linux/arm64" image: apache_centos profiles: - default @@ -19,6 +22,9 @@ services: build: context: . dockerfile: docker/centos7/Dockerfile + platforms: + - "linux/amd64" + - "linux/arm64" image: apache_centos7 hostname: webserver container_name: webserver_centos7 @@ -33,6 +39,9 @@ services: build: context: . dockerfile: docker/ubuntu20.04/Dockerfile + platforms: + - "linux/amd64" + - "linux/arm64" image: apache_ubuntu hostname: webserver container_name: webserver_ubuntu @@ -47,6 +56,9 @@ services: build: context: . dockerfile: Dockerfile + platforms: + - "linux/amd64" + - "linux/arm64" image: nginx_centos hostname: webserver container_name: nginx_centos @@ -61,6 +73,9 @@ services: build: context: . dockerfile: docker/centos7/Dockerfile + platforms: + - "linux/amd64" + - "linux/arm64" image: nginx_centos7 hostname: webserver container_name: nginx_centos7 @@ -75,6 +90,9 @@ services: build: context: . dockerfile: docker/ubuntu20.04/Dockerfile + platforms: + - "linux/amd64" + - "linux/arm64" image: nginx_ubuntu hostname: webserver container_name: nginx_ubuntu diff --git a/instrumentation/otel-webserver-module/docker/centos7/Dockerfile b/instrumentation/otel-webserver-module/docker/centos7/Dockerfile index 60ec1bf5c..fb8f24b0b 100644 --- a/instrumentation/otel-webserver-module/docker/centos7/Dockerfile +++ b/instrumentation/otel-webserver-module/docker/centos7/Dockerfile @@ -1,13 +1,17 @@ FROM centos:7 ARG BUILD_NUMBER +ARG BUILD_ARCH='x64' -LABEL NAME=apm/build-image-webserver-agent-centos6-x64 VERSION=$BUILD_NUMBER +LABEL NAME=apm/build-image-webserver-agent-centos6-${BUILD_ARCH} VERSION=$BUILD_NUMBER -ENV GOSU_ARCH amd64 -ENV JDK_ARCH x64 +ARG GOSU_ARCH='amd64' +ENV GOSU_ARCH=${GOSU_ARCH} +ARG JDK_ARCH='x64' +ENV JDK_ARCH=${JDK_ARCH} -ARG PYTHON_VERSION="2.7.8" +ARG PYTHON_VERSION="2.7.18" +ARG CMAKE_ARCH='x86_64' ARG CMAKE_VERSION="3.20" ARG CMAKE_0VERSION="3.20.0" ARG GRPC_VERSION="1.36.4" @@ -18,6 +22,7 @@ ARG APR_VERSION="1.7.0" ARG EXPAT_VERSION="2.3.0" ARG EXPAT_RVERSION="R_2_3_0" ARG APRUTIL_VERSION="1.6.1" +ARG AUTOCONF_BUILD_TYPE='x86_64-unknown-linux-gnu' ARG AUTOCONF_VERSION="2.68" ARG LIBTOOL_VERSION="2.4.6" ARG LOG4CXX_VERSION="0.11.0" @@ -26,6 +31,7 @@ ARG AUTOMAKE_VERSION="1.16.3" ARG PERL_VERSION="5.20.2" ARG PERL_CPANVERSION="5.0" ARG PCRE_VERSION="8.44" +ARG NGINX_ARCH='x86_64' ARG NGINX_VERSION="1.26.0" # create default non-root user @@ -65,7 +71,7 @@ RUN wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm && yum clean all ENV PATH="/opt/rh/devtoolset-7/root/usr/bin:${PATH}" -# install python 2.7.8 +# install python RUN wget http://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tar.xz \ && unxz Python-${PYTHON_VERSION}.tar.xz \ && tar -xf Python-${PYTHON_VERSION}.tar \ @@ -74,14 +80,14 @@ RUN wget http://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERS && rm -rf Python-${PYTHON_VERSION}.tar.xz && rm -rf Python-${PYTHON_VERSION}.tar # install gosu for easy step-down from root (from https://github.com/tianon/gosu/blob/master/INSTALL.md#from-centos) -ENV GOSU_VERSION=1.10 +ENV GOSU_VERSION=1.11 #RUN gpg --keyserver pgp.mit.edu --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4 \ -# && curl -o /usr/bin/gosu -SL "https://github.com/tianon/gosu/releases/download/${GOSU_VERSION}/gosu-amd64" \ -# && curl -o /usr/bin/gosu.asc -SL "https://github.com/tianon/gosu/releases/download/${GOSU_VERSION}/gosu-amd64.asc" \ +# && curl -o /usr/bin/gosu -SL "https://github.com/tianon/gosu/releases/download/${GOSU_VERSION}/gosu-${GOSU_ARCH}" \ +# && curl -o /usr/bin/gosu.asc -SL "https://github.com/tianon/gosu/releases/download/${GOSU_VERSION}/gosu-${GOSU_ARCH}.asc" \ # && gpg --verify /usr/bin/gosu.asc \ # && rm /usr/bin/gosu.asc \ # && rm -r /root/.gnupg/ \ -RUN curl -o /usr/bin/gosu -SL "https://github.com/tianon/gosu/releases/download/${GOSU_VERSION}/gosu-amd64" \ +RUN curl -o /usr/bin/gosu -SL "https://github.com/tianon/gosu/releases/download/${GOSU_VERSION}/gosu-${GOSU_ARCH}" \ && chmod +x /usr/bin/gosu \ # Verify that the binary works && gosu nobody true @@ -91,11 +97,11 @@ RUN yum install git -y \ && yum clean all # install cmake 3.20 -RUN wget https://cmake.org/files/v${CMAKE_VERSION}/cmake-${CMAKE_0VERSION}-linux-x86_64.tar.gz \ - && tar -xvf cmake-${CMAKE_0VERSION}-linux-x86_64.tar.gz \ - && cd cmake-${CMAKE_0VERSION}-linux-x86_64 \ +RUN wget https://cmake.org/files/v${CMAKE_VERSION}/cmake-${CMAKE_0VERSION}-linux-${CMAKE_ARCH}.tar.gz \ + && tar -xvf cmake-${CMAKE_0VERSION}-linux-${CMAKE_ARCH}.tar.gz \ + && cd cmake-${CMAKE_0VERSION}-linux-${CMAKE_ARCH} \ && cp -rf * /usr/local/ \ - && cd .. && rm -rf cmake-${CMAKE_0VERSION}-linux-x86_64.tar.gz + && cd .. && rm -rf cmake-${CMAKE_0VERSION}-linux-${CMAKE_ARCH}.tar.gz # install grpc. If planning to upgrade, make sure sed command works RUN git clone https://github.com/grpc/grpc \ @@ -170,7 +176,7 @@ ENV PATH=$HOME/localperl/bin:$PATH RUN wget --no-check-certificate https://ftp.gnu.org/gnu/autoconf/autoconf-${AUTOCONF_VERSION}.tar.gz \ && tar xzf autoconf-${AUTOCONF_VERSION}.tar.gz \ && cd autoconf-${AUTOCONF_VERSION} \ - && ./configure --prefix=/usr/ && make -j && make install && autoconf -V \ + && ./configure --prefix=/usr/ --build=${AUTOCONF_BUILD_TYPE} && make -j && make install && autoconf -V \ && cd .. && rm -rf autoconf-${AUTOCONF_VERSION}.tar.gz # install automake @@ -273,13 +279,13 @@ RUN cp -r /dependencies /otel-webserver-module/ \ RUN echo '[nginx]' >> /etc/yum.repos.d/nginx.repo \ && echo 'name=nginx repo' >> /etc/yum.repos.d/nginx.repo \ - && echo 'baseurl=https://nginx.org/packages/centos/7/x86_64' >> /etc/yum.repos.d/nginx.repo \ + && echo "baseurl=https://nginx.org/packages/centos/7/${NGINX_ARCH}" >> /etc/yum.repos.d/nginx.repo \ && echo 'gpgcheck=0' >> /etc/yum.repos.d/nginx.repo \ && echo 'enabled=1' >> /etc/yum.repos.d/nginx.repo \ && yum install nginx-${NGINX_VERSION} -y RUN cd /otel-webserver-module/build \ - && tar -xf opentelemetry-webserver-sdk-x64-linux.tgz \ + && tar -xf opentelemetry-webserver-sdk-${BUILD_ARCH}-linux.tgz \ && mv -f opentelemetry-webserver-sdk /opt/ \ && cd ../ \ && cp opentelemetry_module.conf /etc/httpd/conf/ \ @@ -295,7 +301,7 @@ RUN cp /otel-webserver-module/conf/nginx/opentelemetry_module.conf /opt/ \ && cd / # Remove unwanted files -RUN rm -rf grpc && rm -rf autoconf-${AUTOCONF_VERSION} && rm -rf automake-${AUTOMAKE_VERSION} && rm -rf cmake-${CMAKE_VERSION}-linux-x86_64 \ +RUN rm -rf grpc && rm -rf autoconf-${AUTOCONF_VERSION} && rm -rf automake-${AUTOMAKE_VERSION} && rm -rf cmake-${CMAKE_VERSION}-linux-${CMAKE_ARCH} \ && rm -rf libtool-${LIBTOOL_VERSION} && rm -rf Python-${PYTHON_VERSION} \ && rm -f apr-${APR_VERSION}.tar.gz && rm -f apr-util-${APRUTIL_VERSION}.tar.gz \ && rm -f httpd-2.2.31.tar.gz && rm -f httpd-2.4.23.tar.gz diff --git a/instrumentation/otel-webserver-module/docker/ubuntu20.04/Dockerfile b/instrumentation/otel-webserver-module/docker/ubuntu20.04/Dockerfile index 0df295570..7f948a505 100644 --- a/instrumentation/otel-webserver-module/docker/ubuntu20.04/Dockerfile +++ b/instrumentation/otel-webserver-module/docker/ubuntu20.04/Dockerfile @@ -201,7 +201,7 @@ RUN cp -r /dependencies /otel-webserver-module/ \ && ./gradlew assembleWebServerModule -DtargetSystem=ubuntu RUN cd /otel-webserver-module/build \ - && tar -xf opentelemetry-webserver-sdk-x64-linux.tgz \ + && tar -xf opentelemetry-webserver-sdk-*-linux.tgz \ && mv -f opentelemetry-webserver-sdk /opt/ \ && cd ../ \ && cp opentelemetry_module.conf /etc/apache2/opentelemetry_module.conf \ diff --git a/instrumentation/otel-webserver-module/test/ApacheTesting.sh b/instrumentation/otel-webserver-module/test/ApacheTesting.sh index 171c2ee1f..ebf69d8bd 100755 --- a/instrumentation/otel-webserver-module/test/ApacheTesting.sh +++ b/instrumentation/otel-webserver-module/test/ApacheTesting.sh @@ -5,6 +5,7 @@ # Extract the agent targetSystem=$1 +platform=$2 OTelApacheModule="/opt/opentelemetry-webserver-sdk/WebServerModule/Apache/libmod_apache_otel22.so" if [ $targetSystem = "ubuntu" ] || [ $targetSystem = "centos7" ]; then @@ -12,7 +13,7 @@ if [ $targetSystem = "ubuntu" ] || [ $targetSystem = "centos7" ]; then fi -tar -xf ../build/opentelemetry-webserver-sdk-x64-linux.tgz -C /opt +tar -xf ../build/opentelemetry-webserver-sdk-$platform-linux.tgz -C /opt cd /opt/opentelemetry-webserver-sdk diff --git a/instrumentation/otel-webserver-module/test/NginxTesting.sh b/instrumentation/otel-webserver-module/test/NginxTesting.sh index 5bc8cf437..2e567987f 100755 --- a/instrumentation/otel-webserver-module/test/NginxTesting.sh +++ b/instrumentation/otel-webserver-module/test/NginxTesting.sh @@ -3,7 +3,9 @@ # Bash script for testing Apache Server # Extract the agent -tar -xf ../build/opentelemetry-webserver-sdk-x64-linux.tgz -C /opt +platform=$1 + +tar -xf ../build/opentelemetry-webserver-sdk-$platform-linux.tgz -C /opt cd /opt/opentelemetry-sdk-native diff --git a/instrumentation/otel-webserver-module/test/unit/ApiUtils_test.cpp b/instrumentation/otel-webserver-module/test/unit/ApiUtils_test.cpp index b420dda32..3836f55c7 100644 --- a/instrumentation/otel-webserver-module/test/unit/ApiUtils_test.cpp +++ b/instrumentation/otel-webserver-module/test/unit/ApiUtils_test.cpp @@ -421,5 +421,5 @@ TEST(ApiUtils, getSDKInstallPath) { otel::core::ApiUtils apiUtils; auto path = apiUtils.getSDKInstallPath(); - EXPECT_THAT(path.string(), testing::EndsWith("build/linux-x64/opentelemetry-webserver-sdk")); + EXPECT_THAT(path.string(), testing::MatchesRegex(".*build/linux-(x|arm)64/opentelemetry-webserver-sdk")); } From d9eb65e7030c38cbe68e303cdeacbce50579e4cf Mon Sep 17 00:00:00 2001 From: Trevor Dearham Date: Thu, 2 May 2024 15:18:25 +0100 Subject: [PATCH 2/2] Split Docker files Build arguments are no longer needed --- .github/workflows/webserver.yml | 62 ++-- .../otel-webserver-module/Dockerfile | 34 +- .../otel-webserver-module/docker-compose.yml | 82 +++-- .../docker/centos7-arm64/Dockerfile | 304 ++++++++++++++++++ .../docker/centos7/Dockerfile | 40 +-- .../docker/ubuntu20.04-arm64/Dockerfile | 220 +++++++++++++ .../docker/ubuntu20.04/Dockerfile | 2 +- 7 files changed, 649 insertions(+), 95 deletions(-) create mode 100644 instrumentation/otel-webserver-module/docker/centos7-arm64/Dockerfile create mode 100644 instrumentation/otel-webserver-module/docker/ubuntu20.04-arm64/Dockerfile diff --git a/.github/workflows/webserver.yml b/.github/workflows/webserver.yml index 1cc8c5a55..a03b735e1 100644 --- a/.github/workflows/webserver.yml +++ b/.github/workflows/webserver.yml @@ -13,8 +13,8 @@ on: - '.github/workflows/webserver.yml' jobs: - webserver-build-test-ubuntu-x64: - name: webserver-ubuntu-build-x64 + webserver-build-test-ubuntu: + name: webserver-ubuntu-build runs-on: ubuntu-20.04 steps: - name: checkout otel webserver @@ -24,7 +24,6 @@ jobs: uses: docker/setup-buildx-action@master with: install: true - platforms: linux/amd64 - name: cache docker layers uses: actions/cache@v3 with: @@ -35,18 +34,18 @@ jobs: - name: setup docker image run: | cd instrumentation/otel-webserver-module - docker buildx build -t apache_ubuntu_amd64 -f docker/ubuntu20.04/Dockerfile \ - --cache-from type=local,src=/tmp/buildx-cache/apache_ubuntu_amd64 \ - --cache-to type=local,dest=/tmp/buildx-cache/apache_ubuntu_amd64-new \ + docker buildx build -t apache_ubuntu -f docker/ubuntu20.04/Dockerfile \ + --cache-from type=local,src=/tmp/buildx-cache/apache_ubuntu \ + --cache-to type=local,dest=/tmp/buildx-cache/apache_ubuntu-new \ --load . - name: build run: | - docker run -idt --name apache_ubuntu_container_amd64 apache_ubuntu_amd64 /bin/bash + docker run -idt --name apache_ubuntu_container apache_ubuntu /bin/bash cd instrumentation/otel-webserver-module - docker exec apache_ubuntu_container_amd64 bash -c \ + docker exec apache_ubuntu_container bash -c \ 'cd /otel-webserver-module; rm -rf *;' - docker cp . $(docker inspect --format="{{.Id}}" apache_ubuntu_container_amd64):/otel-webserver-module/ - docker exec apache_ubuntu_container_amd64 bash -c \ + docker cp . $(docker inspect --format="{{.Id}}" apache_ubuntu_container):/otel-webserver-module/ + docker exec apache_ubuntu_container bash -c \ 'cd /otel-webserver-module; rm -rf build; \ cp -r /dependencies /otel-webserver-module/; \ cp -r /build-dependencies /otel-webserver-module/; \ @@ -55,8 +54,8 @@ jobs: - name: update cache run: | - rm -rf /tmp/buildx-cache/apache_ubuntu_amd64 - mv /tmp/buildx-cache/apache_ubuntu_amd64-new /tmp/buildx-cache/apache_ubuntu_amd64 + rm -rf /tmp/buildx-cache/apache_ubuntu + mv /tmp/buildx-cache/apache_ubuntu-new /tmp/buildx-cache/apache_ubuntu webserver-build-test-ubuntu-arm64: name: webserver-ubuntu-build-arm64 @@ -82,7 +81,7 @@ jobs: - name: setup docker image run: | cd instrumentation/otel-webserver-module - docker buildx build -t apache_ubuntu_arm64 -f docker/ubuntu20.04/Dockerfile \ + docker buildx build -t apache_ubuntu_arm64 -f docker/ubuntu20.04-arm64/Dockerfile \ --cache-from type=local,src=/tmp/buildx-cache/apache_ubuntu_arm64 \ --cache-to type=local,dest=/tmp/buildx-cache/apache_ubuntu_arm64-new \ --load . --platform linux/arm64 @@ -128,8 +127,8 @@ jobs: # sleep 30 # ./gradlew :test:integration:integrationTests -i - webserver-build-test-centos7-x64: - name: webserver-centos7-build-x64 + webserver-build-test-centos7: + name: webserver-centos7-build runs-on: ubuntu-20.04 steps: - name: checkout otel webserver @@ -139,7 +138,6 @@ jobs: uses: docker/setup-buildx-action@master with: install: true - platforms: linux/amd64 # - name: cache docker layers # uses: actions/cache@v3 # with: @@ -150,43 +148,43 @@ jobs: - name: setup docker image run: | cd instrumentation/otel-webserver-module - docker buildx build -t apache_centos7_amd64 -f docker/centos7/Dockerfile \ + docker buildx build -t apache_centos7 -f docker/centos7/Dockerfile \ --load . - name: build run: | - docker run -idt --name apache_centos7_container_amd64 apache_centos7_amd64 /bin/bash + docker run -idt --name apache_centos7_container apache_centos7 /bin/bash cd instrumentation/otel-webserver-module - docker exec apache_centos7_container_amd64 bash -c \ + docker exec apache_centos7_container bash -c \ 'cd /otel-webserver-module; rm -rf *;' - docker cp . $(docker inspect --format="{{.Id}}" apache_centos7_container_amd64):/otel-webserver-module/ - docker exec apache_centos7_container_amd64 bash -c \ + docker cp . $(docker inspect --format="{{.Id}}" apache_centos7_container):/otel-webserver-module/ + docker exec apache_centos7_container bash -c \ 'cd /otel-webserver-module; rm -rf build; \ cp -r /dependencies /otel-webserver-module/; \ cp -r /build-dependencies /otel-webserver-module/; \ ./gradlew assembleWebServerModule' - name: unit test run: | - docker exec apache_centos7_container_amd64 bash -c \ + docker exec apache_centos7_container bash -c \ 'cd /otel-webserver-module; ./gradlew runUnitTest' # - name: update cache # run: | - # rm -rf /tmp/buildx-cache/apache_centos7_amd64 - # mv /tmp/buildx-cache/apache_centos7_amd64-new /tmp/buildx-cache/apache_centos7_amd64 + # rm -rf /tmp/buildx-cache/apache_centos7 + # mv /tmp/buildx-cache/apache_centos7-new /tmp/buildx-cache/apache_centos7 - name: copy artifacts id: artifacts run: | cd instrumentation/otel-webserver-module - mkdir -p /tmp/apache_centos7_amd64/ - docker cp apache_centos7_container_amd64:/otel-webserver-module/build/opentelemetry-webserver-sdk-x64-linux.tgz \ - /tmp/apache_centos7_amd64/ + mkdir -p /tmp/apache_centos7/ + docker cp apache_centos7_container:/otel-webserver-module/build/opentelemetry-webserver-sdk-x64-linux.tgz \ + /tmp/apache_centos7/ - name: upload artifacts uses: actions/upload-artifact@v3 with: name: opentelemetry-webserver-sdk-x64-linux.tgz - path: /tmp/apache_centos7_amd64/opentelemetry-webserver-sdk-x64-linux.tgz + path: /tmp/apache_centos7/opentelemetry-webserver-sdk-x64-linux.tgz - name: run integrationtest run: | - docker rm -f apache_centos7_container_amd64 + docker rm -f apache_centos7_container cd instrumentation/otel-webserver-module docker compose --profile centos7 up -d docker ps -a @@ -217,10 +215,8 @@ jobs: - name: setup docker image run: | cd instrumentation/otel-webserver-module - docker buildx build -t apache_centos7_arm64 -f docker/centos7/Dockerfile \ - --load . --platform linux/arm64 --build-arg BUILD_ARCH='arm64' \ - --build-arg CMAKE_ARCH='aarch64' --build-arg GOSU_ARCH='arm64' \ - --build-arg JDK_ARCH='aarch64' --build-arg NGINX_ARCH='aarch64' + docker buildx build -t apache_centos7_arm64 -f docker/centos7-arm64/Dockerfile \ + --load . --platform linux/arm64 - name: build run: | docker run -idt --platform linux/arm64 --name apache_centos7_container_arm64 apache_centos7_arm64 /bin/bash diff --git a/instrumentation/otel-webserver-module/Dockerfile b/instrumentation/otel-webserver-module/Dockerfile index 7979a74e1..6deb7207a 100644 --- a/instrumentation/otel-webserver-module/Dockerfile +++ b/instrumentation/otel-webserver-module/Dockerfile @@ -1,17 +1,13 @@ FROM centos:6.9 ARG BUILD_NUMBER -ARG BUILD_ARCH='x64' -LABEL NAME=apm/build-image-webserver-agent-centos6-${BUILD_ARCH} VERSION=$BUILD_NUMBER +LABEL NAME=apm/build-image-webserver-agent-centos6-x64 VERSION=$BUILD_NUMBER -ARG GOSU_ARCH='amd64' -ENV GOSU_ARCH=${GOSU_ARCH} -ARG JDK_ARCH='x64' -ENV JDK_ARCH=${JDK_ARCH} +ENV GOSU_ARCH amd64 +ENV JDK_ARCH x64 -ARG PYTHON_VERSION="2.7.18" -ARG CMAKE_ARCH='x86_64' +ARG PYTHON_VERSION="2.7.8" ARG CMAKE_VERSION="3.20" ARG CMAKE_0VERSION="3.20.0" ARG GRPC_VERSION="1.36.4" @@ -22,14 +18,12 @@ ARG APR_VERSION="1.7.0" ARG EXPAT_VERSION="2.3.0" ARG EXPAT_RVERSION="R_2_3_0" ARG APRUTIL_VERSION="1.6.1" -ARG AUTOCONF_BUILD_TYPE='x86_64-unknown-linux-gnu' ARG AUTOCONF_VERSION="2.68" ARG LIBTOOL_VERSION="2.4.6" ARG LOG4CXX_VERSION="0.11.0" ARG GTEST_VERSION="1.10.0" ARG AUTOMAKE_VERSION="1.16.3" ARG PCRE_VERSION="8.44" -ARG NGINX_ARCH='x86_64' ARG NGINX_VERSION="1.26.0" @@ -79,9 +73,9 @@ RUN wget http://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERS && rm -rf Python-${PYTHON_VERSION}.tar.xz && rm -rf Python-${PYTHON_VERSION}.tar # install gosu for easy step-down from root (from https://github.com/tianon/gosu/blob/master/INSTALL.md#from-centos) -ENV GOSU_VERSION=1.11 +ENV GOSU_VERSION=1.10 -RUN curl -o /usr/bin/gosu -SL "https://github.com/tianon/gosu/releases/download/${GOSU_VERSION}/gosu-${GOSU_ARCH}" \ +RUN curl -o /usr/bin/gosu -SL "https://github.com/tianon/gosu/releases/download/${GOSU_VERSION}/gosu-amd64" \ && chmod +x /usr/bin/gosu \ # Verify that the binary works && gosu nobody true @@ -91,11 +85,11 @@ RUN yum install git -y \ && yum clean all # install cmake -RUN wget https://cmake.org/files/v${CMAKE_VERSION}/cmake-${CMAKE_0VERSION}-linux-${CMAKE_ARCH}.tar.gz \ - && tar -xvf cmake-${CMAKE_0VERSION}-linux-${CMAKE_ARCH}.tar.gz \ - && cd cmake-${CMAKE_0VERSION}-linux-${CMAKE_ARCH} \ +RUN wget https://cmake.org/files/v${CMAKE_VERSION}/cmake-${CMAKE_0VERSION}-linux-x86_64.tar.gz \ + && tar -xvf cmake-${CMAKE_0VERSION}-linux-x86_64.tar.gz \ + && cd cmake-${CMAKE_0VERSION}-linux-x86_64 \ && cp -rf * /usr/local/ \ - && cd .. && rm -rf cmake-${CMAKE_0VERSION}-linux-${CMAKE_ARCH}.tar.gz + && cd .. && rm -rf cmake-${CMAKE_0VERSION}-linux-x86_64.tar.gz # install grpc. If planning to upgrade, make sure sed command works RUN git clone https://github.com/grpc/grpc \ @@ -158,7 +152,7 @@ RUN yum install m4 -y RUN wget --no-check-certificate https://ftp.gnu.org/gnu/autoconf/autoconf-${AUTOCONF_VERSION}.tar.gz \ && tar xzf autoconf-${AUTOCONF_VERSION}.tar.gz \ && cd autoconf-${AUTOCONF_VERSION} \ - && ./configure --prefix=/usr/ --build=${AUTOCONF_BUILD_TYPE} && make -j && make install && autoconf -V \ + && ./configure --prefix=/usr/ && make -j && make install && autoconf -V \ && cd .. && rm -rf autoconf-${AUTOCONF_VERSION}.tar.gz # install automake @@ -263,13 +257,13 @@ RUN cp -r /dependencies /otel-webserver-module/ \ RUN echo '[nginx]' >> /etc/yum.repos.d/nginx.repo \ && echo 'name=nginx repo' >> /etc/yum.repos.d/nginx.repo \ - && echo "baseurl=https://nginx.org/packages/centos/6/${NGINX_ARCH}" >> /etc/yum.repos.d/nginx.repo \ + && echo 'baseurl=https://nginx.org/packages/centos/6/x86_64' >> /etc/yum.repos.d/nginx.repo \ && echo 'gpgcheck=0' >> /etc/yum.repos.d/nginx.repo \ && echo 'enabled=1' >> /etc/yum.repos.d/nginx.repo \ && yum install nginx -y RUN cd /otel-webserver-module/build \ - && tar -xf opentelemetry-webserver-sdk-${BUILD_ARCH}-linux.tgz \ + && tar -xf opentelemetry-webserver-sdk-x64-linux.tgz \ && mv -f opentelemetry-webserver-sdk /opt/ \ && cd ../ \ && cp opentelemetry_module.conf /etc/httpd/conf/ \ @@ -284,7 +278,7 @@ RUN cp /otel-webserver-module/conf/nginx/opentelemetry_module.conf /opt/ \ && cd / # Remove unwanted files -RUN rm -rf grpc && rm -rf autoconf-${AUTOCONF_VERSION} && rm -rf automake-${AUTOMAKE_VERSION} && rm -rf cmake-${CMAKE_VERSION}-linux-${CMAKE_ARCH} \ +RUN rm -rf grpc && rm -rf autoconf-${AUTOCONF_VERSION} && rm -rf automake-${AUTOMAKE_VERSION} && rm -rf cmake-${CMAKE_VERSION}-linux-x86_64 \ && rm -rf libtool-${LIBTOOL_VERSION} && rm -rf Python-${PYTHON_VERSION} \ && rm -f apr-${APR_VERSION}.tar.gz && rm -f apr-util-${APRUTIL_VERSION}.tar.gz \ && rm -f httpd-2.2.31.tar.gz && rm -f httpd-2.4.23.tar.gz diff --git a/instrumentation/otel-webserver-module/docker-compose.yml b/instrumentation/otel-webserver-module/docker-compose.yml index c95d26e5f..f6f151048 100644 --- a/instrumentation/otel-webserver-module/docker-compose.yml +++ b/instrumentation/otel-webserver-module/docker-compose.yml @@ -7,9 +7,6 @@ services: build: context: . dockerfile: Dockerfile - platforms: - - "linux/amd64" - - "linux/arm64" image: apache_centos profiles: - default @@ -22,9 +19,6 @@ services: build: context: . dockerfile: docker/centos7/Dockerfile - platforms: - - "linux/amd64" - - "linux/arm64" image: apache_centos7 hostname: webserver container_name: webserver_centos7 @@ -35,13 +29,26 @@ services: - "9004:80" depends_on: - otel-collector - webserver_ubuntu: + webserver_centos7-arm64: build: context: . - dockerfile: docker/ubuntu20.04/Dockerfile + dockerfile: docker/centos7-arm64/Dockerfile platforms: - - "linux/amd64" - "linux/arm64" + image: apache_centos7_arm64 + hostname: webserver + container_name: webserver_centos7_arm64 + command: bash -c " httpd -k start && tail -f /dev/null " + profiles: + - centos7 + ports: + - "9004:80" + depends_on: + - otel-collector + webserver_ubuntu: + build: + context: . + dockerfile: docker/ubuntu20.04/Dockerfile image: apache_ubuntu hostname: webserver container_name: webserver_ubuntu @@ -52,13 +59,26 @@ services: - "9000:80" depends_on: - otel-collector - nginx_centos: + webserver_ubuntu-arm64: build: context: . - dockerfile: Dockerfile + dockerfile: docker/ubuntu20.04-arm64/Dockerfile platforms: - - "linux/amd64" - "linux/arm64" + image: apache_ubuntu_arm64 + hostname: webserver + container_name: webserver_ubuntu_arm64 + command: bash -c "apache2ctl -k start && tail -f /dev/null " + profiles: + - ubuntu20.04 + ports: + - "9000:80" + depends_on: + - otel-collector + nginx_centos: + build: + context: . + dockerfile: Dockerfile image: nginx_centos hostname: webserver container_name: nginx_centos @@ -73,9 +93,6 @@ services: build: context: . dockerfile: docker/centos7/Dockerfile - platforms: - - "linux/amd64" - - "linux/arm64" image: nginx_centos7 hostname: webserver container_name: nginx_centos7 @@ -86,13 +103,26 @@ services: - "8012:80" depends_on: - otel-collector - nginx_ubuntu: + nginx_centos7-arm64: build: context: . - dockerfile: docker/ubuntu20.04/Dockerfile + dockerfile: docker/centos7/Dockerfile platforms: - - "linux/amd64" - "linux/arm64" + image: nginx_centos7_arm64 + hostname: webserver + container_name: nginx_centos7_arm64 + command: bash -c "export LD_LIBRARY_PATH=/opt/opentelemetry-webserver-sdk/sdk_lib/lib && nginx && tail -f /dev/null" + profiles: + - centos7_nginx + ports: + - "8012:80" + depends_on: + - otel-collector + nginx_ubuntu: + build: + context: . + dockerfile: docker/ubuntu20.04/Dockerfile image: nginx_ubuntu hostname: webserver container_name: nginx_ubuntu @@ -103,6 +133,22 @@ services: - "8016:80" depends_on: - otel-collector + nginx_ubuntu-arm64: + build: + context: . + dockerfile: docker/ubuntu20.04-arm64/Dockerfile + platforms: + - "linux/arm64" + image: nginx_ubuntu_arm64 + hostname: webserver + container_name: nginx_ubuntu_arm64 + command: bash -c "export LD_LIBRARY_PATH=/opt/opentelemetry-webserver-sdk/sdk_lib/lib && nginx && tail -f /dev/null" + profiles: + - ubuntu20.04_nginx + ports: + - "8016:80" + depends_on: + - otel-collector # Collector diff --git a/instrumentation/otel-webserver-module/docker/centos7-arm64/Dockerfile b/instrumentation/otel-webserver-module/docker/centos7-arm64/Dockerfile new file mode 100644 index 000000000..d02fafb1a --- /dev/null +++ b/instrumentation/otel-webserver-module/docker/centos7-arm64/Dockerfile @@ -0,0 +1,304 @@ +FROM centos:7 + +ARG BUILD_NUMBER + +LABEL NAME=apm/build-image-webserver-agent-centos6-arm64 VERSION=$BUILD_NUMBER + +ENV GOSU_ARCH='arm64' +ENV JDK_ARCH='aarch64' + +ARG PYTHON_VERSION="2.7.18" +ARG CMAKE_VERSION="3.20" +ARG CMAKE_0VERSION="3.20.0" +ARG GRPC_VERSION="1.36.4" +ARG OPENTELEMETRY_VERSION="1.2.0" +ARG BOOST_VERSION="1.75.0" +ARG BOOST_FILENAME="boost_1_75_0" +ARG APR_VERSION="1.7.0" +ARG EXPAT_VERSION="2.3.0" +ARG EXPAT_RVERSION="R_2_3_0" +ARG APRUTIL_VERSION="1.6.1" +ARG AUTOCONF_VERSION="2.68" +ARG LIBTOOL_VERSION="2.4.6" +ARG LOG4CXX_VERSION="0.11.0" +ARG GTEST_VERSION="1.10.0" +ARG AUTOMAKE_VERSION="1.16.3" +ARG PERL_VERSION="5.20.2" +ARG PERL_CPANVERSION="5.0" +ARG PCRE_VERSION="8.44" +ARG NGINX_VERSION="1.26.0" + +# create default non-root user +RUN groupadd -r swuser && useradd -u 1000 -g swuser -m -s /sbin/nologin -c "default non-root user" swuser + +RUN chmod -R 777 /opt + +# RUN curl https://www.getpagespeed.com/files/centos6-eol.repo --output /etc/yum.repos.d/CentOS-Base.repo + +# install required packages +RUN yum update -y \ + && yum install -y \ + yum install wget -y \ + yum install -y zlib-devel \ + yum install -y openssl-devel \ + yum install java-1.8.0-openjdk -y \ + yum install pcre-devel -y \ + yum install xz -y \ + yum install httpd -y \ + && yum clean all + +# install lcov package +RUN wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm \ + && yum install ./epel-release-latest-*.noarch.rpm -y \ + && yum install lcov -y \ + && yum clean all + +# install devtoolset toolchain +# RUN curl https://www.getpagespeed.com/files/centos6-eol.repo --output /etc/yum.repos.d/CentOS-Base.repo \ +# && curl https://www.getpagespeed.com/files/centos6-epel-eol.repo --output /etc/yum.repos.d/epel.repo \ +RUN yum -y install centos-release-scl \ + # && curl https://www.getpagespeed.com/files/centos6-scl-eol.repo --output /etc/yum.repos.d/CentOS-SCLo-scl.repo \ + # && curl https://www.getpagespeed.com/files/centos6-scl-rh-eol.repo --output /etc/yum.repos.d/CentOS-SCLo-scl-rh.repo \ + && yum install yum-utils -y \ + && yum-config-manager --enable rhel-server-rhscl-7-rpms -y \ + && yum install devtoolset-7 -y \ + && yum clean all +ENV PATH="/opt/rh/devtoolset-7/root/usr/bin:${PATH}" + +# install python +RUN wget http://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tar.xz \ + && unxz Python-${PYTHON_VERSION}.tar.xz \ + && tar -xf Python-${PYTHON_VERSION}.tar \ + && cd Python-${PYTHON_VERSION} && ./configure --prefix=/usr/local && make && make install \ + && cd .. \ + && rm -rf Python-${PYTHON_VERSION}.tar.xz && rm -rf Python-${PYTHON_VERSION}.tar + +# install gosu for easy step-down from root (from https://github.com/tianon/gosu/blob/master/INSTALL.md#from-centos) +ENV GOSU_VERSION=1.11 +#RUN gpg --keyserver pgp.mit.edu --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4 \ +# && curl -o /usr/bin/gosu -SL "https://github.com/tianon/gosu/releases/download/${GOSU_VERSION}/gosu-arm64" \ +# && curl -o /usr/bin/gosu.asc -SL "https://github.com/tianon/gosu/releases/download/${GOSU_VERSION}/gosu-arm64.asc" \ +# && gpg --verify /usr/bin/gosu.asc \ +# && rm /usr/bin/gosu.asc \ +# && rm -r /root/.gnupg/ \ +RUN curl -o /usr/bin/gosu -SL "https://github.com/tianon/gosu/releases/download/${GOSU_VERSION}/gosu-arm64" \ + && chmod +x /usr/bin/gosu \ + # Verify that the binary works + && gosu nobody true + +# install git required for grpc +RUN yum install git -y \ + && yum clean all + +# install cmake 3.20 +RUN wget https://cmake.org/files/v${CMAKE_VERSION}/cmake-${CMAKE_0VERSION}-linux-aarch64.tar.gz \ + && tar -xvf cmake-${CMAKE_0VERSION}-linux-aarch64.tar.gz \ + && cd cmake-${CMAKE_0VERSION}-linux-aarch64 \ + && cp -rf * /usr/local/ \ + && cd .. && rm -rf cmake-${CMAKE_0VERSION}-linux-aarch64.tar.gz + +# install grpc. If planning to upgrade, make sure sed command works +RUN git clone https://github.com/grpc/grpc \ + && cd grpc \ + && git checkout tags/v${GRPC_VERSION} -b v${GRPC_VERSION} \ + && git submodule update --init \ + && sed -i "s/target_link_libraries(bssl ssl crypto)/target_link_libraries(bssl ssl crypto rt)/g" third_party/boringssl-with-bazel/CMakeLists.txt \ + && mkdir -p cmake/build \ + && cd cmake/build \ + && cmake ../.. -DgRPC_INSTALL=ON -DCMAKE_BUILD_TYPE=Release -DgRPC_ABSL_PROVIDER=module -DgRPC_CARES_PROVIDER=module -DgRPC_PROTOBUF_PROVIDER=module -DgRPC_RE2_PROVIDER=module -DgRPC_SSL_PROVIDER=module -DgRPC_ZLIB_PROVIDER=module \ + && make \ + && make install \ + && cd ../../.. + +# Create dependencies folder to store all dependencies. +RUN mkdir -p dependencies + +# install boost version 1.75.0 +RUN wget https://boostorg.jfrog.io/artifactory/main/release/${BOOST_VERSION}/source/${BOOST_FILENAME}_rc1.tar.gz \ + && tar -xvf ${BOOST_FILENAME}_rc1.tar.gz \ + && cd ${BOOST_FILENAME} \ + && ./bootstrap.sh --with-libraries=filesystem,system --prefix=/dependencies/boost/${BOOST_VERSION}/ \ + && ./b2 install define=BOOST_ERROR_CODE_HEADER_ONLY link=static threading=multi cxxflags="-fvisibility=hidden -fPIC" cflags="-fvisibility=hidden -fPIC" \ + && cd .. && rm -rf ${BOOST_FILENAME} && rm ${BOOST_FILENAME}_rc1.tar.gz + +#install Apr +RUN mkdir -p dependencies/apr/${APR_VERSION} \ + && wget https://archive.apache.org/dist/apr/apr-${APR_VERSION}.tar.gz --no-check-certificate \ + && tar -xf apr-${APR_VERSION}.tar.gz \ + && cd apr-${APR_VERSION} \ + && ./configure --prefix=/dependencies/apr/${APR_VERSION} --enable-static=yes --enable-shared=no --with-pic && echo $? \ + && make -j 6 \ + && make install \ + && cd ../ && rm -rf apr-${APR_VERSION} && rm -rf apr-${APR_VERSION}.tar.gz + +# install libexpat +RUN mkdir -p dependencies/expat/${EXPAT_VERSION} \ + && wget https://github.com/libexpat/libexpat/releases/download/${EXPAT_RVERSION}/expat-${EXPAT_VERSION}.tar.gz --no-check-certificate \ + && tar -xf expat-${EXPAT_VERSION}.tar.gz \ + && cd expat-${EXPAT_VERSION} \ + && ./configure --prefix=/dependencies/expat/${EXPAT_VERSION} --enable-static=yes --enable-shared=no --with-pic && echo $? \ + && make -j 6 \ + && make install \ + && cd ../ && rm -rf expat-${EXPAT_VERSION} && rm -rf expat-${EXPAT_VERSION}.tar.gz + +# install Apr-util +RUN mkdir -p dependencies/apr-util/${APRUTIL_VERSION} \ + && wget https://archive.apache.org/dist/apr/apr-util-${APRUTIL_VERSION}.tar.gz --no-check-certificate \ + && tar -xf apr-util-${APRUTIL_VERSION}.tar.gz \ + && cd apr-util-${APRUTIL_VERSION} \ + && ./configure --prefix=/dependencies/apr-util/${APRUTIL_VERSION} --enable-static=yes --enable-shared=no --with-pic --with-apr=/dependencies/apr/${APR_VERSION} --with-expat=/dependencies/expat/${EXPAT_VERSION} && echo $? \ + && make -j 6 \ + && make install \ + && cd ../ && rm -rf apr-util-${APRUTIL_VERSION} && rm -rf apr-util-${APRUTIL_VERSION}.tar.gz + +# install m4 +RUN yum install m4 -y \ + && yum install perl-Data-Dumper -y + +# Update perl version +RUN yum install perl-Thread-Queue.noarch -y \ + && wget http://www.cpan.org/src/${PERL_CPANVERSION}/perl-${PERL_VERSION}.tar.gz \ + && tar -xzf perl-${PERL_VERSION}.tar.gz \ + && cd perl-${PERL_VERSION} \ + && ./Configure -des -Dprefix=$HOME/localperl \ + && make \ + && make test; echo 0 \ + && make install +ENV PATH=$HOME/localperl/bin:$PATH + +# install autoconf +RUN wget --no-check-certificate https://ftp.gnu.org/gnu/autoconf/autoconf-${AUTOCONF_VERSION}.tar.gz \ + && tar xzf autoconf-${AUTOCONF_VERSION}.tar.gz \ + && cd autoconf-${AUTOCONF_VERSION} \ + && ./configure --prefix=/usr/ --build=aarch64-unknown-linux-gnu && make -j && make install && autoconf -V \ + && cd .. && rm -rf autoconf-${AUTOCONF_VERSION}.tar.gz + +# install automake +RUN wget --no-check-certificate https://ftp.gnu.org/gnu/automake/automake-${AUTOMAKE_VERSION}.tar.gz \ + && tar xzf automake-${AUTOMAKE_VERSION}.tar.gz \ + && cd automake-${AUTOMAKE_VERSION} \ + && ./configure --prefix=/usr --libdir=/usr/lib64 \ + && make -j && make install \ + && automake --version \ + && cd .. && rm -rf automake-${AUTOMAKE_VERSION}.tar.gz + +# install libtool +RUN wget --no-check-certificate https://ftpmirror.gnu.org/libtool/libtool-${LIBTOOL_VERSION}.tar.gz \ + && tar xzf libtool-${LIBTOOL_VERSION}.tar.gz \ + && cd libtool-${LIBTOOL_VERSION} \ + && ./configure --prefix=/usr \ + && make -j 6 \ + && make install \ + && libtool --version \ + && cd .. && rm -rf libtool--${LIBTOOL_VERSION}.tar.gz + +#install log4cxx +RUN mkdir -p dependencies/apache-log4cxx/${LOG4CXX_VERSION} \ + && wget https://archive.apache.org/dist/logging/log4cxx/${LOG4CXX_VERSION}/apache-log4cxx-${LOG4CXX_VERSION}.tar.gz --no-check-certificate \ + && tar -xf apache-log4cxx-${LOG4CXX_VERSION}.tar.gz \ + && cd apache-log4cxx-${LOG4CXX_VERSION} \ + && ./configure --prefix=/dependencies/apache-log4cxx/${LOG4CXX_VERSION}/ --enable-static=yes --enable-shared=no --with-pic --with-apr=/dependencies/apr/${APR_VERSION}/ --with-apr-util=/dependencies/apr-util/${APRUTIL_VERSION}/ && echo $? \ + && make -j 6 ; echo 0 \ + && automake --add-missing \ + && make install \ + && cd .. && rm -rf apache-log4cxx-${LOG4CXX_VERSION}.tar.gz && rm -rf apache-log4cxx-${LOG4CXX_VERSION} + +# install opentelemetry +RUN mkdir -p dependencies/opentelemetry/${OPENTELEMETRY_VERSION}/lib \ + && mkdir -p dependencies/opentelemetry/${OPENTELEMETRY_VERSION}/include \ + && git clone https://github.com/open-telemetry/opentelemetry-cpp \ + && cd opentelemetry-cpp/ \ + && git checkout tags/v${OPENTELEMETRY_VERSION} -b v${OPENTELEMETRY_VERSION} \ + && git submodule update --init --recursive \ + && mkdir build \ + && cd build \ + && cmake .. -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DBUILD_TESTING=OFF -DBUILD_SHARED_LIBS=ON -DWITH_OTLP=ON -DCMAKE_INSTALL_PREFIX=/dependencies/opentelemetry/${OPENTELEMETRY_VERSION} \ + && cmake --build . --target all \ + && cd .. \ + && find . -name "*.so" -type f -exec cp {} /dependencies/opentelemetry/${OPENTELEMETRY_VERSION}/lib/ \; \ + && cp build/libopentelemetry_proto.a /dependencies/opentelemetry/${OPENTELEMETRY_VERSION}/lib \ + && cp -r api/include/ /dependencies/opentelemetry/${OPENTELEMETRY_VERSION}/ \ + && for dir in exporters/*; do if [ -d "$dir" ]; then cp -rf "$dir/include" /dependencies/opentelemetry/${OPENTELEMETRY_VERSION}/; fi; done \ + && cp -r sdk/include/ /dependencies/opentelemetry/${OPENTELEMETRY_VERSION}/ \ + && cp -r build/generated/third_party/opentelemetry-proto/opentelemetry/proto/ /dependencies/opentelemetry/${OPENTELEMETRY_VERSION}/include/opentelemetry/ \ + && cd .. && rm -rf opentelemetry-cpp + +# install googletest +RUN mkdir -p dependencies/googletest/${GTEST_VERSION}/ \ + && wget https://github.com/google/googletest/archive/refs/tags/release-${GTEST_VERSION}.tar.gz --no-check-certificate \ + && tar -xf release-${GTEST_VERSION}.tar.gz \ + && cd googletest-release-${GTEST_VERSION}/ \ + && mkdir build && cd build \ + && cmake .. -DCMAKE_INSTALL_PREFIX=/dependencies/googletest/${GTEST_VERSION}/ \ + && make \ + && make install \ + && cd ../.. && rm -rf release-${GTEST_VERSION}.tar.gz && rm -rf googletest-release-${GTEST_VERSION}/ + +# install pcre +RUN mkdir -p dependencies/pcre/${PCRE_VERSION}/ \ + && wget https://ftp.exim.org/pub/pcre/pcre-${PCRE_VERSION}.tar.gz --no-check-certificate \ + && tar -xvf pcre-${PCRE_VERSION}.tar.gz \ + && cd pcre-${PCRE_VERSION} \ + && ./configure --prefix=/dependencies/pcre/${PCRE_VERSION} --enable-jit \ + && make && make install \ + && cd .. && rm -rf ${PCRE_VERSION}.tar.gz && rm -rf pcre-${PCRE_VERSION} + +#Installing Apache and apr source code +RUN mkdir build-dependencies \ + && wget --no-check-certificate https://archive.apache.org/dist/apr/apr-${APR_VERSION}.tar.gz \ + && tar -xf apr-${APR_VERSION}.tar.gz \ + && mv -f apr-${APR_VERSION} build-dependencies \ + && wget --no-check-certificate https://archive.apache.org/dist/apr/apr-util-${APRUTIL_VERSION}.tar.gz \ + && tar -xf apr-util-${APRUTIL_VERSION}.tar.gz \ + && mv -f apr-util-${APRUTIL_VERSION} build-dependencies \ + && wget --no-check-certificate http://archive.apache.org/dist/httpd/httpd-2.2.31.tar.gz \ + && tar -xf httpd-2.2.31.tar.gz \ + && mv -f httpd-2.2.31 build-dependencies \ + && wget --no-check-certificate http://archive.apache.org/dist/httpd/httpd-2.4.23.tar.gz \ + && tar -xf httpd-2.4.23.tar.gz \ + && mv -f httpd-2.4.23 build-dependencies + +# install nginx +RUN wget http://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz \ + && tar -xvf nginx-${NGINX_VERSION}.tar.gz -C /build-dependencies \ + && rm -rf nginx-${NGINX_VERSION}.tar.gz + +# Build Webserver Module +COPY . /otel-webserver-module + +RUN cp -r /dependencies /otel-webserver-module/ \ + && cp -r /build-dependencies /otel-webserver-module/ \ + && cd otel-webserver-module \ + && ./gradlew assembleWebServerModule + +RUN echo '[nginx]' >> /etc/yum.repos.d/nginx.repo \ + && echo 'name=nginx repo' >> /etc/yum.repos.d/nginx.repo \ + && echo 'baseurl=https://nginx.org/packages/centos/7/aarch64' >> /etc/yum.repos.d/nginx.repo \ + && echo 'gpgcheck=0' >> /etc/yum.repos.d/nginx.repo \ + && echo 'enabled=1' >> /etc/yum.repos.d/nginx.repo \ + && yum install nginx-${NGINX_VERSION} -y + +RUN cd /otel-webserver-module/build \ + && tar -xf opentelemetry-webserver-sdk-arm64-linux.tgz \ + && mv -f opentelemetry-webserver-sdk /opt/ \ + && cd ../ \ + && cp opentelemetry_module.conf /etc/httpd/conf/ \ + && sed -i "s/libmod_apache_otel22.so/libmod_apache_otel.so/g" /etc/httpd/conf/opentelemetry_module.conf \ + && echo 'Include conf/opentelemetry_module.conf' >> /etc/httpd/conf/httpd.conf \ + && cd /opt/opentelemetry-webserver-sdk \ + && ./install.sh \ + && cd / + +RUN cp /otel-webserver-module/conf/nginx/opentelemetry_module.conf /opt/ \ + && sed -i '8i load_module /opt/opentelemetry-webserver-sdk/WebServerModule/Nginx/1.26.0/ngx_http_opentelemetry_module.so;' /etc/nginx/nginx.conf \ + && sed -i '33i include /opt/opentelemetry_module.conf;' /etc/nginx/nginx.conf \ + && cd / + +# Remove unwanted files +RUN rm -rf grpc && rm -rf autoconf-${AUTOCONF_VERSION} && rm -rf automake-${AUTOMAKE_VERSION} && rm -rf cmake-${CMAKE_VERSION}-linux-aarch64 \ + && rm -rf libtool-${LIBTOOL_VERSION} && rm -rf Python-${PYTHON_VERSION} \ + && rm -f apr-${APR_VERSION}.tar.gz && rm -f apr-util-${APRUTIL_VERSION}.tar.gz \ + && rm -f httpd-2.2.31.tar.gz && rm -f httpd-2.4.23.tar.gz + +COPY entrypoint.sh /usr/local/bin/ +ENTRYPOINT ["entrypoint.sh"] \ No newline at end of file diff --git a/instrumentation/otel-webserver-module/docker/centos7/Dockerfile b/instrumentation/otel-webserver-module/docker/centos7/Dockerfile index fb8f24b0b..60ec1bf5c 100644 --- a/instrumentation/otel-webserver-module/docker/centos7/Dockerfile +++ b/instrumentation/otel-webserver-module/docker/centos7/Dockerfile @@ -1,17 +1,13 @@ FROM centos:7 ARG BUILD_NUMBER -ARG BUILD_ARCH='x64' -LABEL NAME=apm/build-image-webserver-agent-centos6-${BUILD_ARCH} VERSION=$BUILD_NUMBER +LABEL NAME=apm/build-image-webserver-agent-centos6-x64 VERSION=$BUILD_NUMBER -ARG GOSU_ARCH='amd64' -ENV GOSU_ARCH=${GOSU_ARCH} -ARG JDK_ARCH='x64' -ENV JDK_ARCH=${JDK_ARCH} +ENV GOSU_ARCH amd64 +ENV JDK_ARCH x64 -ARG PYTHON_VERSION="2.7.18" -ARG CMAKE_ARCH='x86_64' +ARG PYTHON_VERSION="2.7.8" ARG CMAKE_VERSION="3.20" ARG CMAKE_0VERSION="3.20.0" ARG GRPC_VERSION="1.36.4" @@ -22,7 +18,6 @@ ARG APR_VERSION="1.7.0" ARG EXPAT_VERSION="2.3.0" ARG EXPAT_RVERSION="R_2_3_0" ARG APRUTIL_VERSION="1.6.1" -ARG AUTOCONF_BUILD_TYPE='x86_64-unknown-linux-gnu' ARG AUTOCONF_VERSION="2.68" ARG LIBTOOL_VERSION="2.4.6" ARG LOG4CXX_VERSION="0.11.0" @@ -31,7 +26,6 @@ ARG AUTOMAKE_VERSION="1.16.3" ARG PERL_VERSION="5.20.2" ARG PERL_CPANVERSION="5.0" ARG PCRE_VERSION="8.44" -ARG NGINX_ARCH='x86_64' ARG NGINX_VERSION="1.26.0" # create default non-root user @@ -71,7 +65,7 @@ RUN wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm && yum clean all ENV PATH="/opt/rh/devtoolset-7/root/usr/bin:${PATH}" -# install python +# install python 2.7.8 RUN wget http://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tar.xz \ && unxz Python-${PYTHON_VERSION}.tar.xz \ && tar -xf Python-${PYTHON_VERSION}.tar \ @@ -80,14 +74,14 @@ RUN wget http://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERS && rm -rf Python-${PYTHON_VERSION}.tar.xz && rm -rf Python-${PYTHON_VERSION}.tar # install gosu for easy step-down from root (from https://github.com/tianon/gosu/blob/master/INSTALL.md#from-centos) -ENV GOSU_VERSION=1.11 +ENV GOSU_VERSION=1.10 #RUN gpg --keyserver pgp.mit.edu --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4 \ -# && curl -o /usr/bin/gosu -SL "https://github.com/tianon/gosu/releases/download/${GOSU_VERSION}/gosu-${GOSU_ARCH}" \ -# && curl -o /usr/bin/gosu.asc -SL "https://github.com/tianon/gosu/releases/download/${GOSU_VERSION}/gosu-${GOSU_ARCH}.asc" \ +# && curl -o /usr/bin/gosu -SL "https://github.com/tianon/gosu/releases/download/${GOSU_VERSION}/gosu-amd64" \ +# && curl -o /usr/bin/gosu.asc -SL "https://github.com/tianon/gosu/releases/download/${GOSU_VERSION}/gosu-amd64.asc" \ # && gpg --verify /usr/bin/gosu.asc \ # && rm /usr/bin/gosu.asc \ # && rm -r /root/.gnupg/ \ -RUN curl -o /usr/bin/gosu -SL "https://github.com/tianon/gosu/releases/download/${GOSU_VERSION}/gosu-${GOSU_ARCH}" \ +RUN curl -o /usr/bin/gosu -SL "https://github.com/tianon/gosu/releases/download/${GOSU_VERSION}/gosu-amd64" \ && chmod +x /usr/bin/gosu \ # Verify that the binary works && gosu nobody true @@ -97,11 +91,11 @@ RUN yum install git -y \ && yum clean all # install cmake 3.20 -RUN wget https://cmake.org/files/v${CMAKE_VERSION}/cmake-${CMAKE_0VERSION}-linux-${CMAKE_ARCH}.tar.gz \ - && tar -xvf cmake-${CMAKE_0VERSION}-linux-${CMAKE_ARCH}.tar.gz \ - && cd cmake-${CMAKE_0VERSION}-linux-${CMAKE_ARCH} \ +RUN wget https://cmake.org/files/v${CMAKE_VERSION}/cmake-${CMAKE_0VERSION}-linux-x86_64.tar.gz \ + && tar -xvf cmake-${CMAKE_0VERSION}-linux-x86_64.tar.gz \ + && cd cmake-${CMAKE_0VERSION}-linux-x86_64 \ && cp -rf * /usr/local/ \ - && cd .. && rm -rf cmake-${CMAKE_0VERSION}-linux-${CMAKE_ARCH}.tar.gz + && cd .. && rm -rf cmake-${CMAKE_0VERSION}-linux-x86_64.tar.gz # install grpc. If planning to upgrade, make sure sed command works RUN git clone https://github.com/grpc/grpc \ @@ -176,7 +170,7 @@ ENV PATH=$HOME/localperl/bin:$PATH RUN wget --no-check-certificate https://ftp.gnu.org/gnu/autoconf/autoconf-${AUTOCONF_VERSION}.tar.gz \ && tar xzf autoconf-${AUTOCONF_VERSION}.tar.gz \ && cd autoconf-${AUTOCONF_VERSION} \ - && ./configure --prefix=/usr/ --build=${AUTOCONF_BUILD_TYPE} && make -j && make install && autoconf -V \ + && ./configure --prefix=/usr/ && make -j && make install && autoconf -V \ && cd .. && rm -rf autoconf-${AUTOCONF_VERSION}.tar.gz # install automake @@ -279,13 +273,13 @@ RUN cp -r /dependencies /otel-webserver-module/ \ RUN echo '[nginx]' >> /etc/yum.repos.d/nginx.repo \ && echo 'name=nginx repo' >> /etc/yum.repos.d/nginx.repo \ - && echo "baseurl=https://nginx.org/packages/centos/7/${NGINX_ARCH}" >> /etc/yum.repos.d/nginx.repo \ + && echo 'baseurl=https://nginx.org/packages/centos/7/x86_64' >> /etc/yum.repos.d/nginx.repo \ && echo 'gpgcheck=0' >> /etc/yum.repos.d/nginx.repo \ && echo 'enabled=1' >> /etc/yum.repos.d/nginx.repo \ && yum install nginx-${NGINX_VERSION} -y RUN cd /otel-webserver-module/build \ - && tar -xf opentelemetry-webserver-sdk-${BUILD_ARCH}-linux.tgz \ + && tar -xf opentelemetry-webserver-sdk-x64-linux.tgz \ && mv -f opentelemetry-webserver-sdk /opt/ \ && cd ../ \ && cp opentelemetry_module.conf /etc/httpd/conf/ \ @@ -301,7 +295,7 @@ RUN cp /otel-webserver-module/conf/nginx/opentelemetry_module.conf /opt/ \ && cd / # Remove unwanted files -RUN rm -rf grpc && rm -rf autoconf-${AUTOCONF_VERSION} && rm -rf automake-${AUTOMAKE_VERSION} && rm -rf cmake-${CMAKE_VERSION}-linux-${CMAKE_ARCH} \ +RUN rm -rf grpc && rm -rf autoconf-${AUTOCONF_VERSION} && rm -rf automake-${AUTOMAKE_VERSION} && rm -rf cmake-${CMAKE_VERSION}-linux-x86_64 \ && rm -rf libtool-${LIBTOOL_VERSION} && rm -rf Python-${PYTHON_VERSION} \ && rm -f apr-${APR_VERSION}.tar.gz && rm -f apr-util-${APRUTIL_VERSION}.tar.gz \ && rm -f httpd-2.2.31.tar.gz && rm -f httpd-2.4.23.tar.gz diff --git a/instrumentation/otel-webserver-module/docker/ubuntu20.04-arm64/Dockerfile b/instrumentation/otel-webserver-module/docker/ubuntu20.04-arm64/Dockerfile new file mode 100644 index 000000000..0c9b95445 --- /dev/null +++ b/instrumentation/otel-webserver-module/docker/ubuntu20.04-arm64/Dockerfile @@ -0,0 +1,220 @@ +FROM ubuntu:20.04 +ENV DEBIAN_FRONTEND noninteractive + +RUN apt-get -y update && apt-get -y upgrade && apt-get -y dist-upgrade +RUN apt-get install -qq -y --ignore-missing \ + build-essential \ + curl \ + git \ + make \ + pkg-config \ + protobuf-compiler \ + libprotobuf-dev \ + python \ + sudo \ + tar \ + zip \ + unzip \ + wget \ + cmake + +RUN apt-get install -y \ + lcov \ + m4 \ + autoconf \ + automake \ + libtool \ + default-jre + +# The following arguments would be passed from docker-compose.yml +ARG GRPC_VERSION="1.36.4" +ARG OPENTELEMETRY_VERSION="1.2.0" +ARG BOOST_VERSION="1.75.0" +ARG BOOST_FILENAME="boost_1_75_0" +ARG APR_VERSION="1.7.0" +ARG EXPAT_VERSION="2.3.0" +ARG EXPAT_RVERSION="R_2_3_0" +ARG APRUTIL_VERSION="1.6.1" +ARG LOG4CXX_VERSION="0.11.0" +ARG GTEST_VERSION="1.10.0" +ARG PCRE_VERSION="8.44" +ARG NGINX_VERSION="1.26.0" + +# Install GRPC +RUN git clone --shallow-submodules --depth 1 --recurse-submodules -b v${GRPC_VERSION} \ + https://github.com/grpc/grpc \ + && 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 \ + ../.. \ + && make -j2 \ + && make install \ + && cd ../../.. + +# install opentelemetry +RUN mkdir -p dependencies/opentelemetry/${OPENTELEMETRY_VERSION}/lib \ + && mkdir -p dependencies/opentelemetry/${OPENTELEMETRY_VERSION}/include \ + && git clone https://github.com/open-telemetry/opentelemetry-cpp \ + && cd opentelemetry-cpp/ \ + && git checkout tags/v${OPENTELEMETRY_VERSION} -b v${OPENTELEMETRY_VERSION} \ + && git submodule update --init --recursive \ + && mkdir build \ + && cd build \ + && cmake .. -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DBUILD_TESTING=OFF -DBUILD_SHARED_LIBS=ON -DWITH_OTLP=ON -DCMAKE_INSTALL_PREFIX=/dependencies/opentelemetry/${OPENTELEMETRY_VERSION} \ + && cmake --build . --target all \ + && cd .. \ + && find . -name "*.so" -type f -exec cp {} /dependencies/opentelemetry/${OPENTELEMETRY_VERSION}/lib/ \; \ + && cp build/libopentelemetry_proto.a /dependencies/opentelemetry/${OPENTELEMETRY_VERSION}/lib \ + && cp -r api/include/ /dependencies/opentelemetry/${OPENTELEMETRY_VERSION}/ \ + && for dir in exporters/*; do if [ -d "$dir" ]; then cp -rf "$dir/include" /dependencies/opentelemetry/${OPENTELEMETRY_VERSION}/; fi; done \ + && cp -r sdk/include/ /dependencies/opentelemetry/${OPENTELEMETRY_VERSION}/ \ + && cp -r build/generated/third_party/opentelemetry-proto/opentelemetry/proto/ /dependencies/opentelemetry/${OPENTELEMETRY_VERSION}/include/opentelemetry/ \ + && cd .. && rm -rf opentelemetry-cpp + +#install Apr +RUN mkdir -p dependencies/apr/${APR_VERSION} \ + && wget https://archive.apache.org/dist/apr/apr-${APR_VERSION}.tar.gz --no-check-certificate \ + && tar -xf apr-${APR_VERSION}.tar.gz \ + && cd apr-${APR_VERSION} \ + && ./configure --prefix=/dependencies/apr/${APR_VERSION} --enable-static=yes --enable-shared=no --with-pic && echo $? \ + && make -j 6 \ + && make install \ + && cd ../ && rm -rf apr-${APR_VERSION} && rm -rf apr-${APR_VERSION}.tar.gz + +# install libexpat +RUN mkdir -p dependencies/expat/${EXPAT_VERSION} \ + && wget https://github.com/libexpat/libexpat/releases/download/${EXPAT_RVERSION}/expat-${EXPAT_VERSION}.tar.gz --no-check-certificate \ + && tar -xf expat-${EXPAT_VERSION}.tar.gz \ + && cd expat-${EXPAT_VERSION} \ + && ./configure --prefix=/dependencies/expat/${EXPAT_VERSION} --enable-static=yes --enable-shared=no --with-pic && echo $? \ + && make -j 6 \ + && make install \ + && cd ../ && rm -rf expat-${EXPAT_VERSION} && rm -rf expat-${EXPAT_VERSION}.tar.gz + +# install Apr-util +RUN mkdir -p dependencies/apr-util/${APRUTIL_VERSION} \ + && wget https://archive.apache.org/dist/apr/apr-util-${APRUTIL_VERSION}.tar.gz --no-check-certificate \ + && tar -xf apr-util-${APRUTIL_VERSION}.tar.gz \ + && cd apr-util-${APRUTIL_VERSION} \ + && ./configure --prefix=/dependencies/apr-util/${APRUTIL_VERSION} --enable-static=yes --enable-shared=no --with-pic --with-apr=/dependencies/apr/1.7.0 --with-expat=/dependencies/expat/2.3.0 && echo $? \ + && make -j 6 \ + && make install \ + && cd ../ && rm -rf apr-util-${APRUTIL_VERSION} && rm -rf apr-util-${APRUTIL_VERSION}.tar.gz + + +#install log4cxx +RUN mkdir -p dependencies/apache-log4cxx/${LOG4CXX_VERSION} \ + && wget https://archive.apache.org/dist/logging/log4cxx/${LOG4CXX_VERSION}/apache-log4cxx-${LOG4CXX_VERSION}.tar.gz --no-check-certificate \ + && tar -xf apache-log4cxx-${LOG4CXX_VERSION}.tar.gz \ + && cd apache-log4cxx-${LOG4CXX_VERSION} \ + && ./configure --prefix=/dependencies/apache-log4cxx/${LOG4CXX_VERSION}/ --enable-static=yes --enable-shared=no --with-pic --with-apr=/dependencies/apr/1.7.0/ --with-apr-util=/dependencies/apr-util/1.6.1/ && echo $? \ + && make -j 6 ; echo 0 \ + && automake --add-missing \ + && make install \ + && cd .. && rm -rf apache-log4cxx-${LOG4CXX_VERSION}.tar.gz && rm -rf apache-log4cxx-${LOG4CXX_VERSION} + +# install googletest +RUN mkdir -p dependencies/googletest/${GTEST_VERSION}/ \ + && wget https://github.com/google/googletest/archive/refs/tags/release-${GTEST_VERSION}.tar.gz --no-check-certificate \ + && tar -xf release-${GTEST_VERSION}.tar.gz \ + && cd googletest-release-${GTEST_VERSION}/ \ + && mkdir build && cd build \ + && cmake .. -DCMAKE_INSTALL_PREFIX=/dependencies/googletest/${GTEST_VERSION}/ \ + && make \ + && make install \ + && cd ../.. && rm -rf release-${GTEST_VERSION}.tar.gz && rm -rf googletest-release-${GTEST_VERSION}/ + +#Installing Apache and apr source code +RUN mkdir build-dependencies \ + && wget --no-check-certificate https://archive.apache.org/dist/apr/apr-${APR_VERSION}.tar.gz \ + && tar -xf apr-${APR_VERSION}.tar.gz \ + && mv -f apr-${APR_VERSION} build-dependencies \ + && wget --no-check-certificate https://archive.apache.org/dist/apr/apr-util-${APRUTIL_VERSION}.tar.gz \ + && tar -xf apr-util-${APRUTIL_VERSION}.tar.gz \ + && mv -f apr-util-${APRUTIL_VERSION} build-dependencies \ + && wget --no-check-certificate http://archive.apache.org/dist/httpd/httpd-2.2.31.tar.gz \ + && tar -xf httpd-2.2.31.tar.gz \ + && mv -f httpd-2.2.31 build-dependencies \ + && wget --no-check-certificate http://archive.apache.org/dist/httpd/httpd-2.4.23.tar.gz \ + && tar -xf httpd-2.4.23.tar.gz \ + && mv -f httpd-2.4.23 build-dependencies + +RUN rm -rf apr-util-${APRUTIL_VERSION} && rm -rf apr-util-${APRUTIL_VERSION}.tar.gz \ + && rm -rf httpd-2.4.23.tar.gz && rm -rf httpd-2.2.31.tar.gz \ + && rm -rf grpc \ + && rm -rf apr-${APR_VERSION} && rm -rf apr-${APR_VERSION}.tar.gz + +RUN apt-get install libpcre3 libpcre3-dev -y +RUN apt-get install apache2 -y && a2enmod proxy && a2enmod proxy_http \ + && a2enmod proxy_balancer && a2enmod dav + +#Build and install boost +RUN wget https://boostorg.jfrog.io/artifactory/main/release/${BOOST_VERSION}/source/${BOOST_FILENAME}.tar.gz \ + && tar -xvf ${BOOST_FILENAME}.tar.gz \ + && cd ${BOOST_FILENAME} \ + && ./bootstrap.sh --with-libraries=filesystem,system --prefix=/dependencies/boost/${BOOST_VERSION}/ \ + && ./b2 install define=BOOST_ERROR_CODE_HEADER_ONLY link=static threading=multi cxxflags="-fvisibility=hidden -fPIC" cflags="-fvisibility=hidden -fPIC" \ + && cd .. && rm -rf ${BOOST_FILENAME} && rm ${BOOST_FILENAME}.tar.gz + +# install pcre +RUN mkdir -p dependencies/pcre/${PCRE_VERSION}/ \ + && wget https://ftp.exim.org/pub/pcre/pcre-${PCRE_VERSION}.tar.gz --no-check-certificate \ + && tar -xvf pcre-${PCRE_VERSION}.tar.gz \ + && cd pcre-${PCRE_VERSION} \ + && ./configure --prefix=/dependencies/pcre/${PCRE_VERSION} --enable-jit \ + && make && make install \ + && cd .. && rm -rf ${PCRE_VERSION}.tar.gz && rm -rf pcre-${PCRE_VERSION} + +# install nginx +RUN wget http://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz \ + && tar -xvf nginx-${NGINX_VERSION}.tar.gz -C /build-dependencies \ + && rm -rf nginx-${NGINX_VERSION}.tar.gz + +# Install Nginx stable version +RUN apt install curl gnupg2 ca-certificates lsb-release ubuntu-keyring -y \ + && curl https://nginx.org/keys/nginx_signing.key | gpg --dearmor \ + | tee /usr/share/keyrings/nginx-archive-keyring.gpg >/dev/null \ + && gpg --dry-run --quiet --import --import-options import-show /usr/share/keyrings/nginx-archive-keyring.gpg; exit 0 +RUN echo "deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg] \ + http://nginx.org/packages/ubuntu `lsb_release -cs` nginx" \ + | tee /etc/apt/sources.list.d/nginx.list \ + && echo "Package: *\nPin: origin nginx.org\nPin: release o=nginx\nPin-Priority: 900\n" \ + | tee /etc/apt/preferences.d/99nginx \ + && apt update -y && apt install nginx -y + +# Build Webserver Module +COPY . /otel-webserver-module + +RUN cp -r /dependencies /otel-webserver-module/ \ + && cp -r /build-dependencies /otel-webserver-module/ \ + && cd otel-webserver-module \ + && ./gradlew assembleWebServerModule -DtargetSystem=ubuntu + +RUN cd /otel-webserver-module/build \ + && tar -xf opentelemetry-webserver-sdk-*-linux.tgz \ + && mv -f opentelemetry-webserver-sdk /opt/ \ + && cd ../ \ + && cp opentelemetry_module.conf /etc/apache2/opentelemetry_module.conf \ + && sed -i "s/libmod_apache_otel22.so/libmod_apache_otel.so/g" /etc/apache2/opentelemetry_module.conf \ + && echo 'Include opentelemetry_module.conf' >> /etc/apache2/apache2.conf \ + && cd /opt/opentelemetry-webserver-sdk \ + && ./install.sh \ + && cd / + +RUN cd /otel-webserver-module/build \ + && cp ../conf/nginx/opentelemetry_module.conf /opt/ \ + && sed -i '5i load_module /opt/opentelemetry-webserver-sdk/WebServerModule/Nginx/1.26.0/ngx_http_opentelemetry_module.so;' /etc/nginx/nginx.conf \ + && sed -i '33i include /opt/opentelemetry_module.conf;' /etc/nginx/nginx.conf \ + && cd /opt/opentelemetry-webserver-sdk \ + && ./install.sh \ + && cd / \ No newline at end of file diff --git a/instrumentation/otel-webserver-module/docker/ubuntu20.04/Dockerfile b/instrumentation/otel-webserver-module/docker/ubuntu20.04/Dockerfile index 7f948a505..0df295570 100644 --- a/instrumentation/otel-webserver-module/docker/ubuntu20.04/Dockerfile +++ b/instrumentation/otel-webserver-module/docker/ubuntu20.04/Dockerfile @@ -201,7 +201,7 @@ RUN cp -r /dependencies /otel-webserver-module/ \ && ./gradlew assembleWebServerModule -DtargetSystem=ubuntu RUN cd /otel-webserver-module/build \ - && tar -xf opentelemetry-webserver-sdk-*-linux.tgz \ + && tar -xf opentelemetry-webserver-sdk-x64-linux.tgz \ && mv -f opentelemetry-webserver-sdk /opt/ \ && cd ../ \ && cp opentelemetry_module.conf /etc/apache2/opentelemetry_module.conf \