diff --git a/.github/workflows/dependencies_image.yml b/.github/workflows/dependencies_image.yml new file mode 100644 index 0000000000..aa7d923071 --- /dev/null +++ b/.github/workflows/dependencies_image.yml @@ -0,0 +1,46 @@ +name: 'OpenTelemetry-cpp dependencies image' +on: + schedule: + - cron: "0 3 * * 6" + +jobs: + docker_image: + name: Docker Image + runs-on: ubuntu-latest + timeout-minutes: 300 + steps: + - + name: checkout + uses: actions/checkout@v2 + - + name: Set up QEMU + uses: docker/setup-qemu-action@v1 + - + name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v1 + - + name: Build Image + uses: docker/build-push-action@v2 + with: + builder: ${{ steps.buildx.outputs.name }} + context: ci/ + file: ./docker/Dockerfile + build-args: BASE_IMAGE=ubuntu:latest + platforms: linux/amd64 + # platforms: linux/amd64,linux/arm64 + push: false + tags: otel-cpp-deps + load: true + - + name: Save Image + run: | + docker images + docker save -o /opt/otel-cpp-deps-debian.tar otel-cpp-deps + - + name: Upload Image + uses: actions/upload-artifact@v3 + with: + name: otel-cpp-deps + path: /opt/otel-cpp-deps-debian.tar + retention-days: 14 diff --git a/ci/setup_grpc.sh b/ci/setup_grpc.sh index 2995f7b4ba..d42fbb7d2e 100755 --- a/ci/setup_grpc.sh +++ b/ci/setup_grpc.sh @@ -10,13 +10,17 @@ new_grpc_version='v1.43.2' gcc_version_for_new_grpc='5.1' install_grpc_version=${new_grpc_version} grpc_version='v1.39.0' -usage() { echo "Usage: $0 -v " 1>&2; exit 1; } +install_dir='/usr/local/' +usage() { echo "Usage: $0 [-v ] [-i "] 1>&2; exit 1;} -while getopts ":v:" o; do +while getopts ":v:i:" o; do case "${o}" in v) gcc_version=${OPTARG} ;; + i) + install_dir=${OPTARG} + ;; *) usage ;; @@ -34,7 +38,7 @@ if ! type cmake > /dev/null; then exit 1 fi export BUILD_DIR=/tmp/ -export INSTALL_DIR=/usr/local/ +export INSTALL_DIR=${install_dir} pushd $BUILD_DIR echo "installing grpc version: ${install_grpc_version}" git clone --depth=1 -b ${install_grpc_version} https://github.com/grpc/grpc diff --git a/ci/setup_thrift.sh b/ci/setup_thrift.sh index af8cc3ffc8..98e14d5e71 100755 --- a/ci/setup_thrift.sh +++ b/ci/setup_thrift.sh @@ -4,6 +4,17 @@ set -e export DEBIAN_FRONTEND=noninteractive export THRIFT_VERSION=0.14.1 +install_dir='/usr/local/' +while getopts ":i:" o; do + case "${o}" in + i) + install_dir=${OPTARG} + ;; + *) + ;; + esac +done + apt update if ! type cmake > /dev/null; then @@ -11,7 +22,7 @@ if ! type cmake > /dev/null; then exit 1 fi export BUILD_DIR=/tmp/ -export INSTALL_DIR=/usr/local/ +export INSTALL_DIR=${install_dir} apt install -y --no-install-recommends \ libboost-locale-dev \ @@ -44,6 +55,8 @@ cmake -G Ninja .. \ -DWITH_BOOSTTHREADS=OFF \ -DWITH_BOOST_FUNCTIONAL=OFF \ -DWITH_BOOST_SMART_PTR=OFF \ + -DCMAKE_INSTALL_PREFIX=$INSTALL_DIR \ + -DCMAKE_PREFIX_PATH=$INSTALL_DIR \ .. ninja -j $(nproc) diff --git a/docker/Dockerfile.debian.deps b/docker/Dockerfile.debian.deps new file mode 100644 index 0000000000..0634c11970 --- /dev/null +++ b/docker/Dockerfile.debian.deps @@ -0,0 +1,43 @@ +ARG BASE_IMAGE=ubuntu:latest +ARG CORES=${nproc} + +FROM ${BASE_IMAGE} as base + +ENV DEBIAN_FRONTEND=noninteractive + +RUN apt-get update && apt-get install -y build-essential autoconf \ + libtool pkg-config cmake git libssl-dev curl \ + libcurl4-openssl-dev libgtest-dev libgmock-dev libbenchmark-dev + +WORKDIR /work +RUN mkdir -p /opt/otel-cpp + +FROM base as grpc +# install grpc, protobuf and abseil +ARG GRPC_VERSION=1.43.2 + +ADD setup_grpc.sh . +RUN ./setup_grpc.sh -i "/opt/otel-cpp" -v ${GRPC_VERSION} + +FROM base as thrift +RUN apt-get install -y --no-install-recommends wget + +# install thrift +ARG THRIFT_VERSION=0.14.1 +ADD setup_thrift.sh . +RUN ./setup_thrift.sh -i "/opt/otel-cpp" + +FROM scratch as final + +COPY --from=grpc /opt/otel-cpp / +COPY --from=thrift /opt/otel-cpp / + +# how to use: +# +# docker create -ti --name deps otel-cpp-deps bash +# docker cp deps:/ ./ +# docker rm -f deps +# +# or: +# +# COPY --from=otel-cpp-deps /usr