From beedd7803a1ec28a78a31dac7954d24ea0a0da45 Mon Sep 17 00:00:00 2001 From: Maksym Sobolyev Date: Tue, 23 Jul 2024 22:13:19 -0700 Subject: [PATCH] + ee6bb606c780b --- .github/workflows/rtpproxy_ci.yml | 25 ++++++++++++++++++------- docker/Dockerfile | 3 +++ docker/Dockerfile.export_ccache | 2 ++ docker/build.sh | 4 ++-- 4 files changed, 25 insertions(+), 9 deletions(-) create mode 100644 docker/Dockerfile.export_ccache diff --git a/.github/workflows/rtpproxy_ci.yml b/.github/workflows/rtpproxy_ci.yml index 9b4e875c8..00c3c6287 100644 --- a/.github/workflows/rtpproxy_ci.yml +++ b/.github/workflows/rtpproxy_ci.yml @@ -406,8 +406,9 @@ jobs: env: DOCKER_REPO: sippylabs/rtpproxy LOCAL_REPO: localhost:5000/sippylabs/rtpproxy - PLATFORMS: linux/amd64 #,linux/i386,linux/arm/v7,linux/arm64 + PLATFORMS: linux/amd64,linux/i386,linux/arm/v7,linux/arm64 BASE_IMAGE: debian:12-slim + CCACHE_ROOT: ccache steps: - name: Checkout repository uses: actions/checkout@v4 @@ -449,13 +450,14 @@ jobs: - name: Cache the compiler cache uses: actions/cache@v4 with: - path: ccache + path: ${{ env.CCACHE_ROOT }} key: dockerhub-ccache-${{ github.run_id }} restore-keys: | dockerhub-ccache - name: Get branch name - run: echo "GIT_BRANCH=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_ENV + run: | + echo "GIT_BRANCH=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_ENV - name: Build Docker image uses: docker/build-push-action@v6 @@ -464,10 +466,11 @@ jobs: with: context: . file: ./docker/Dockerfile - build-args: BASE_IMAGE=${{ env.BASE_IMAGE }} + build-args: | + BASE_IMAGE=${{ env.BASE_IMAGE }} + CCACHE_ROOT=${{ env.CCACHE_ROOT }} tags: ${{ env.LOCAL_REPO }}:latest platforms: ${{ env.PLATFORMS }} - outputs: type=tar,dest=/tmp/ccache_export.tar push: true cache-from: ${{ env.CACHE_SPEC }} cache-to: ${{ env.CACHE_SPEC }},mode=max @@ -490,8 +493,16 @@ jobs: DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} run: sh -x docker/update_description.sh docker/README.md + - name: Save Docker image + uses: docker/build-push-action@v6 + with: + file: ./docker/Dockerfile.export_ccache + build-args: BASE_IMAGE=${{ env.LOCAL_REPO }}:latest + platforms: ${{ env.PLATFORMS }} + outputs: type=tar,dest=/tmp/ccache_export.tar + - name: Extract ccaches run: | - rm -rf ccache + tar -tvf /tmp/ccache_export.tar tar --strip-components=2 --no-wildcards-match-slash --wildcards -x -f /tmp/ccache_export.tar "*/rtpproxy/ccache" - du -d1 -h ccache + du -d1 -h ${{ env.CCACHE_ROOT }} diff --git a/docker/Dockerfile b/docker/Dockerfile index 077c6d127..3f583a1a7 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -20,6 +20,9 @@ COPY docker/install_depends.sh /tmp RUN ./install_depends.sh COPY --exclude=.git* --link . /rtpproxy/ + +ARG CCACHE_ROOT + WORKDIR /rtpproxy RUN /rtpproxy/docker/build.sh diff --git a/docker/Dockerfile.export_ccache b/docker/Dockerfile.export_ccache new file mode 100644 index 000000000..b9af9b687 --- /dev/null +++ b/docker/Dockerfile.export_ccache @@ -0,0 +1,2 @@ +ARG BASE_IMAGE +FROM $BASE_IMAGE AS build diff --git a/docker/build.sh b/docker/build.sh index 8619473a5..2e6144f0d 100755 --- a/docker/build.sh +++ b/docker/build.sh @@ -16,7 +16,7 @@ fi cd "${RTPDIR}" -CCACHE_ROOT="${RTPDIR}/ccache" +CCACHE_ROOT="${CCACHE_ROOT:-"${RTPDIR}/ccache"}" export PATH="/usr/lib/ccache:${PATH}" export CCACHE_DIR="${CCACHE_ROOT}/${ARCH}" if [ ! -e "${CCACHE_DIR}" ] @@ -39,7 +39,7 @@ ccache --zero-stats CC=clang-15 AR=llvm-ar-15 RANLIB=llvm-ranlib-15 NM=llvm-nm-15 \ STRIP=llvm-strip-15 CFLAGS="-O3 -pipe" ./configure ${CONFIGURE_ARGS} -make all +make -j all make install ccache --show-stats