Skip to content

Commit

Permalink
dependencies image as artifact (#1333)
Browse files Browse the repository at this point in the history
Co-authored-by: Lalit Kumar Bhasin <lalit_fin@yahoo.com>
  • Loading branch information
esigo and lalitb authored Apr 18, 2022
1 parent 2e9b7a1 commit 1d2cd42
Show file tree
Hide file tree
Showing 4 changed files with 110 additions and 4 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/dependencies_image.yml
Original file line number Diff line number Diff line change
@@ -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
10 changes: 7 additions & 3 deletions ci/setup_grpc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 <gcc-version>" 1>&2; exit 1; }
install_dir='/usr/local/'
usage() { echo "Usage: $0 [-v <gcc-version>] [-i <install_dir>"] 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
;;
Expand All @@ -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
Expand Down
15 changes: 14 additions & 1 deletion ci/setup_thrift.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,25 @@ 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
#cmake not installed, exiting
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 \
Expand Down Expand Up @@ -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)
Expand Down
43 changes: 43 additions & 0 deletions docker/Dockerfile.debian.deps
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 1d2cd42

Please sign in to comment.