Skip to content

fix: Remove old untagged Docker images #63

fix: Remove old untagged Docker images

fix: Remove old untagged Docker images #63

Workflow file for this run

name: Docker CI
on:
push:
branches: ["master"]
paths:
- "**Dockerfile"
- "**docker_ci.yml"
- "**EposCmd**"
env:
REGISTRY: ghcr.io
IMAGE_NAME: epflxplore/docker_commons
jobs:
delete-untagged-images:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Delete all untagged images from repository
uses: Chizkiyahu/delete-untagged-ghcr-action@v3
with:
token: ${{ secrets.PAT_TOKEN }}
repository_owner: ${{ github.repository_owner }}
owner_type: org
repository: ${{ github.repository }}
untagged_only: true
build-and-push-image:
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
include:
- dockerfile: ./docker_foxy_desktop/Dockerfile
context: ./docker_foxy_desktop
target: gazebo_nvidia
tag: foxy-desktop-nvidia
platform: linux/amd64
- dockerfile: ./docker_foxy_desktop/Dockerfile
context: ./docker_foxy_desktop
target: xplore_common
tag: foxy-desktop
platform: linux/amd64, linux/arm64
- dockerfile: ./docker_humble_desktop/Dockerfile
context: ./docker_humble_desktop
target: gazebo_nvidia
tag: humble-desktop-nvidia
platform: linux/amd64
- dockerfile: ./docker_humble_desktop/Dockerfile
context: ./docker_humble_desktop
target: xplore_common
tag: humble-desktop
platform: linux/amd64, linux/arm64
- dockerfile: ./docker_foxy_jetson/Dockerfile
context: ./docker_foxy_jetson
target: gazebo_nvidia
tag: foxy-jetson
platform: linux/arm64
- dockerfile: ./docker_humble_jetson/Dockerfile
context: ./docker_humble_jetson
target: gazebo_nvidia
tag: humble-jetson
platform: linux/arm64
permissions:
contents: read
packages: write
steps:
- name: Check disk space
run: df . -h
- name: Free disk space
run: |
sudo docker rmi $(docker image ls -aq) >/dev/null 2>&1 || true
sudo rm -rf \
/usr/share/dotnet /usr/local/lib/android /opt/ghc \
/usr/local/share/powershell /usr/share/swift /usr/local/.ghcup \
/usr/lib/jvm || true
echo "some directories deleted"
sudo apt install aptitude -y >/dev/null 2>&1
sudo aptitude purge aria2 ansible azure-cli shellcheck rpm xorriso zsync \
esl-erlang firefox gfortran-8 gfortran-9 google-chrome-stable \
google-cloud-sdk imagemagick \
libmagickcore-dev libmagickwand-dev libmagic-dev ant ant-optional kubectl \
mercurial apt-transport-https mono-complete libmysqlclient \
unixodbc-dev yarn chrpath libssl-dev libxft-dev \
libfreetype6 libfreetype6-dev libfontconfig1 libfontconfig1-dev \
snmp pollinate libpq-dev postgresql-client powershell ruby-full \
sphinxsearch subversion mongodb-org azure-cli microsoft-edge-stable \
-y -f >/dev/null 2>&1
sudo aptitude purge google-cloud-sdk -f -y >/dev/null 2>&1
sudo aptitude purge microsoft-edge-stable -f -y >/dev/null 2>&1 || true
sudo apt purge microsoft-edge-stable -f -y >/dev/null 2>&1 || true
sudo aptitude purge '~n ^mysql' -f -y >/dev/null 2>&1
sudo aptitude purge '~n ^php' -f -y >/dev/null 2>&1
sudo aptitude purge '~n ^dotnet' -f -y >/dev/null 2>&1
sudo apt-get autoremove -y >/dev/null 2>&1
sudo apt-get autoclean -y >/dev/null 2>&1
echo "some packages purged"
- name: Check disk space
run: |
sudo dpkg-query -Wf '${Installed-Size}\t${Package}\n' | sort -nr | head
df . -h
sudo du /usr/ -hx -d 4 --threshold=1G | sort -hr | head
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Docker Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
file: ${{ matrix.dockerfile }}
context: ${{ matrix.context }}
target: ${{ matrix.target }}
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ matrix.tag }}
platforms: ${{ matrix.platform }}
no-cache: false
pull: false
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:cache-${{ matrix.tag }}
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:cache-${{ matrix.tag }},mode=max
push: true