Skip to content

Reduce CI-built docker image size #9

Reduce CI-built docker image size

Reduce CI-built docker image size #9

Workflow file for this run

name: Ubuntu
on:
push:
branches:
- master
pull_request:
schedule:
- cron: '0 5 * * 6'
workflow_dispatch:
jobs:
industrial_ci:
name: ${{ matrix.distro }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
distro: [foxy, humble, rolling]
env:
CI_NAME: ${{ matrix.distro }}-Build
CCACHE_DIR: "/home/runner/work/tesseract_ros2/tesseract_ros2/${{ matrix.distro }}-Build/.ccache"
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
PUSH_DOCKER_IMAGE: ${{ github.ref == 'refs/heads/master' || github.event_name == 'release' }}
steps:
- uses: actions/checkout@v1
- name: Free Disk Space
continue-on-error: true
run: |
sudo swapoff -a
sudo rm -f /swapfile
sudo apt clean
docker rmi $(docker image ls -aq)
df -h
- name: Prepare ccache timestamp
id: ccache_cache_timestamp
shell: cmake -P {0}
run: |
string(TIMESTAMP current_date "%Y-%m-%d-%H;%M;%S" UTC)
message("::set-output name=timestamp::${current_date}")
- name: ccache cache files
continue-on-error: true
uses: actions/[email protected]
with:
path: ${{ env.CI_NAME }}/.ccache
key: ${{ env.CI_NAME }}-ccache-${{ steps.ccache_cache_timestamp.outputs.timestamp }}
restore-keys: |
${{ env.CI_NAME }}-ccache-
- name: Login to Github container registry
uses: docker/login-action@v1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract Docker meta-information
id: meta
uses: docker/metadata-action@v3
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
flavor: |
latest=false
prefix=
suffix=
tags: |
type=ref,event=branch,prefix=${{ matrix.distro }}-
type=semver,pattern={{major}}.{{minor}},prefix=${{ matrix.distro }}-
- name: Set build type
run: |
if [[ "${{ env.PUSH_DOCKER_IMAGE }}" = true ]]
then
echo "BUILD_TYPE=Release" >> $GITHUB_ENV
else
echo "BUILD_TYPE=Debug" >> $GITHUB_ENV
fi
- uses: 'ros-industrial/industrial_ci@master'
env:
OS_NAME: ubuntu
ROS_DISTRO: ${{ matrix.distro }}
ROS_REPO: main
BEFORE_INIT: './.add-gazebo-ppa'
UPSTREAM_WORKSPACE: 'dependencies_unstable.repos'
ROSDEP_SKIP_KEYS: "catkin taskflow fcl gz-common5 gz-math7 gz-rendering7"
ADDITIONAL_DEBS: "libgz-common5-dev libgz-math7-dev libgz-rendering7-dev"
DOCKER_IMAGE: "ros:${{ matrix.distro }}"
PARALLEL_TESTS: false
NOT_TEST_BUILD: true
UPSTREAM_CMAKE_ARGS: "-DCMAKE_BUILD_TYPE=Release"
TARGET_CMAKE_ARGS: "-DCMAKE_BUILD_TYPE=Debug"
BEFORE_RUN_TARGET_TEST_EMBED: "source /root/target_ws/install/local_setup.bash"
AFTER_SCRIPT: 'rm -r $BASEDIR/${PREFIX}upstream_ws/build $BASEDIR/${PREFIX}target_ws/build'
DOCKER_COMMIT: ${{ steps.meta.outputs.tags }}
- name: Push post-build Docker
if: ${{ env.PUSH_DOCKER_IMAGE == 'true' }}
run: docker push ${{ steps.meta.outputs.tags }}