diff --git a/.github/scripts/cleanup_docker.sh b/.github/scripts/cleanup_docker.sh deleted file mode 100644 index 4d4a786b..00000000 --- a/.github/scripts/cleanup_docker.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/bash - -# Docker Cleanup Script - -echo "=====================================" -echo " Starting Docker Cleanup " -echo "=====================================" - -# Remove stopped containers -echo "Removing stopped containers..." -docker container prune -f - -# Remove unused volumes -echo "Removing unused volumes..." -docker volume ls -q | grep -v -E "qualitylab-pro-backend_mysql-volume|quality-lab-pro-react-plotly_qualitylab_node_modules|quality-lab-pro-react-plotly_qualitylab_public" | xargs -r docker volume rm - - -# Remove unused images -echo "Removing unused images..." -docker image prune -a -f - -# Remove unused networks -echo "Removing unused networks..." -docker network prune -f - -# Remove build cache -echo "Removing build cache..." -docker builder prune -a -f - -echo "=====================================" -echo " Docker Cleanup Completed " -echo "=====================================" - -# Show disk usage after cleanup -echo "Disk usage after cleanup:" -docker system df - -exit 0 \ No newline at end of file diff --git a/.github/scripts/cleanup_system.sh b/.github/scripts/cleanup_system.sh new file mode 100644 index 00000000..dce992f3 --- /dev/null +++ b/.github/scripts/cleanup_system.sh @@ -0,0 +1,49 @@ +#!/bin/bash + +# Docker Cleanup Script + +echo "=====================================" +echo " Starting Docker Cleanup " +echo "=====================================" + +echo "Remove everything unused" +docker system prune -a -f + +echo "=====================================" +echo " Docker Cleanup Completed " +echo "=====================================" + +echo "Disk usage after cleanup:" +docker system df + +echo "=====================================" +echo " Starting System Cleanup " +echo "=====================================" +echo "Clearing system cache..." +sync +echo 3 > /proc/sys/vm/drop_caches + +echo "Memory usage after cleanup:" +free -h + +echo "=====================================" +echo " Starting APT Cleanup " +echo "=====================================" + +echo "Cleaning APT cache..." +apt-get clean -y + +echo "Removing unused packages..." +apt-get autoremove -y + +echo "Removing old downloaded archive files..." +apt-get autoclean -y + +echo "Current disk usage:" +df -h + +echo "=====================================" +echo " Cleanup Complete " +echo "=====================================" + +exit 0 \ No newline at end of file diff --git a/.github/scripts/bk.json b/.github/scripts/trivy.yml similarity index 80% rename from .github/scripts/bk.json rename to .github/scripts/trivy.yml index 079183cf..ae108a97 100644 --- a/.github/scripts/bk.json +++ b/.github/scripts/trivy.yml @@ -1,6 +1,6 @@ name: Run Trivy vulnerability scanner - uses: aquasecurity/trivy-action@master + uses: aquasecurity/trivy-action@master with: scan-type: 'fs' scan-ref: '.' diff --git a/.github/workflows/backend-deploy.yml b/.github/workflows/backend-deploy.yml index bac3f1f3..4d5ee11a 100644 --- a/.github/workflows/backend-deploy.yml +++ b/.github/workflows/backend-deploy.yml @@ -114,10 +114,10 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Cleanup Docker resources + - name: Running cleanup script run: | - chmod +x ./.github/scripts/cleanup_docker.sh - ./.github/scripts/cleanup_docker.sh + chmod +x ./.github/scripts/cleanup_system.sh + ./.github/scripts/cleanup_system.sh notify: runs-on: [ self-hosted, linux, x64, backend ] diff --git a/README.md b/README.md index f083c677..ac06c248 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,8 @@ # QualityLab Pro-API RESTful for internal laboratory quality control. -[![Docker Image CI/CD](https://github.com/LabGraphTeam/LabGraph-Back-End/actions/workflows/docker-image.yml/badge.svg?branch=master)](https://github.com/LabGraphTeam/LabGraph-Back-End/actions/workflows/docker-image.yml) +[![Docker Image CI/CD](https://github.com/LabGraphTeam/LabGraph-Back-End/actions/workflows/backend-deploy.yml/badge.svg?branch=master)](https://github.com/LabGraphTeam/LabGraph-Back-End/actions/workflows/backend-deploy.yml)
+