Enhance disk cleanup script with discovery and additional cleanup #10
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| on: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - 'Dockerfile_apache_tika' | |
| - '.github/workflows/build_apache_tika.yaml' | |
| tags: | |
| - "v*" | |
| workflow_dispatch: | |
| name: Build and Test Apache Tika container image | |
| permissions: | |
| contents: read | |
| packages: write | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| test-apache-tika: | |
| name: Test Apache Tika on multiple architectures | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - platform: linux/amd64 | |
| runner: ubuntu-latest | |
| arch: amd64 | |
| - platform: linux/arm64 | |
| runner: ubuntu-24.04-arm | |
| arch: arm64 | |
| runs-on: ${{ matrix.runner }} | |
| timeout-minutes: 30 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Free up disk space | |
| run: ./.github/scripts/free_disk_space.sh | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| with: | |
| driver-opts: | | |
| image=moby/buildkit:v0.12.5 | |
| - name: Build Apache Tika test image for ${{ matrix.platform }} | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| file: ./Dockerfile_apache_tika | |
| platforms: ${{ matrix.platform }} | |
| load: ${{ matrix.platform == 'linux/amd64' }} | |
| cache-from: type=gha,scope=tika-test-${{ matrix.arch }} | |
| cache-to: type=gha,mode=min,scope=tika-test-${{ matrix.arch }} | |
| tags: | | |
| test-apache-tika:${{ matrix.arch }} | |
| - name: Test Apache Tika server | |
| run: | | |
| # Start Tika server | |
| CONTAINER_ID=$(docker run -d -p 9998:9998 test-apache-tika:${{ matrix.arch }}) | |
| echo "Waiting for Tika server to start on ${{ matrix.platform }}..." | |
| sleep 15 | |
| # Test if Tika is responding (with retry) | |
| TIKA_READY=false | |
| for i in {1..6}; do | |
| if curl -f http://localhost:9998/version > /dev/null 2>&1; then | |
| TIKA_READY=true | |
| break | |
| fi | |
| echo "Attempt $i/6: Tika not ready yet, waiting 5 more seconds..." | |
| sleep 5 | |
| done | |
| if [ "$TIKA_READY" = true ]; then | |
| echo "✅ Apache Tika server is responding on ${{ matrix.platform }}" | |
| TIKA_VERSION=$(curl -s http://localhost:9998/version) | |
| echo "✅ Tika version: $TIKA_VERSION" | |
| else | |
| echo "❌ Apache Tika server is not responding after 45 seconds on ${{ matrix.platform }}" | |
| echo "Container logs:" | |
| docker logs $CONTAINER_ID | |
| docker stop $CONTAINER_ID | |
| exit 1 | |
| fi | |
| # Cleanup | |
| docker stop $CONTAINER_ID | |
| - name: Clean up test images | |
| if: always() | |
| run: | | |
| docker system prune -f | |
| docker image prune -af | |
| build-apache-tika: | |
| name: Build Apache Tika container image | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - platform: linux/amd64 | |
| runner: ubuntu-latest | |
| arch: amd64 | |
| - platform: linux/arm64 | |
| runner: ubuntu-24.04-arm | |
| arch: arm64 | |
| runs-on: ${{ matrix.runner }} | |
| needs: [test-apache-tika] | |
| timeout-minutes: 30 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Free up disk space | |
| run: ./.github/scripts/free_disk_space.sh | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| with: | |
| driver-opts: | | |
| image=moby/buildkit:v0.12.5 | |
| - name: Login to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.repository_owner }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build and push Apache Tika development container image | |
| if: ${{ startsWith(github.ref, 'refs/heads/') }} | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| file: ./Dockerfile_apache_tika | |
| platforms: ${{ matrix.platform }} | |
| push: true | |
| cache-from: type=gha,scope=tika-main-${{ matrix.arch }} | |
| cache-to: type=gha,mode=max,scope=tika-main-${{ matrix.arch }} | |
| tags: | | |
| ghcr.io/okfn-brasil/querido-diario-apache-tika-server:latest-${{ matrix.arch }} | |
| - name: Build and push Apache Tika tagged container image | |
| if: ${{ startsWith(github.ref, 'refs/tags/') }} | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| file: ./Dockerfile_apache_tika | |
| platforms: ${{ matrix.platform }} | |
| push: true | |
| cache-from: type=gha,scope=tika-tag-${{ matrix.arch }} | |
| cache-to: type=gha,mode=max,scope=tika-tag-${{ matrix.arch }} | |
| tags: | | |
| ghcr.io/okfn-brasil/querido-diario-apache-tika-server:${{ github.ref_name }}-${{ matrix.arch }} | |
| create-apache-tika-manifest: | |
| name: Create Apache Tika multi-arch manifest | |
| runs-on: ubuntu-latest | |
| needs: build-apache-tika | |
| timeout-minutes: 15 | |
| steps: | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.repository_owner }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Verify single-arch images availability (branch) | |
| if: ${{ startsWith(github.ref, 'refs/heads/') }} | |
| run: | | |
| for tag in latest-amd64 latest-arm64; do | |
| for i in {1..20}; do | |
| if docker buildx imagetools inspect ghcr.io/okfn-brasil/querido-diario-apache-tika-server:$tag > /dev/null 2>&1; then | |
| echo "Found ghcr.io/okfn-brasil/querido-diario-apache-tika-server:$tag"; | |
| break; | |
| fi | |
| echo "Waiting for ghcr.io/okfn-brasil/querido-diario-apache-tika-server:$tag to be available ($i/20)..."; | |
| sleep 3; | |
| done | |
| done | |
| - name: Create and push Apache Tika development manifest | |
| if: ${{ startsWith(github.ref, 'refs/heads/') }} | |
| run: | | |
| docker buildx imagetools create \ | |
| -t ghcr.io/okfn-brasil/querido-diario-apache-tika-server:latest \ | |
| ghcr.io/okfn-brasil/querido-diario-apache-tika-server:latest-amd64 \ | |
| ghcr.io/okfn-brasil/querido-diario-apache-tika-server:latest-arm64 | |
| - name: Verify single-arch images availability (tag) | |
| if: ${{ startsWith(github.ref, 'refs/tags/') }} | |
| run: | | |
| for arch in amd64 arm64; do | |
| for i in {1..20}; do | |
| if docker buildx imagetools inspect ghcr.io/okfn-brasil/querido-diario-apache-tika-server:${{ github.ref_name }}-$arch > /dev/null 2>&1; then | |
| echo "Found ghcr.io/okfn-brasil/querido-diario-apache-tika-server:${{ github.ref_name }}-$arch"; | |
| break; | |
| fi | |
| echo "Waiting for ghcr.io/okfn-brasil/querido-diario-apache-tika-server:${{ github.ref_name }}-$arch to be available ($i/20)..."; | |
| sleep 3; | |
| done | |
| done | |
| - name: Create and push Apache Tika tagged manifest | |
| if: ${{ startsWith(github.ref, 'refs/tags/') }} | |
| run: | | |
| docker buildx imagetools create \ | |
| -t ghcr.io/okfn-brasil/querido-diario-apache-tika-server:${{ github.ref_name }} \ | |
| ghcr.io/okfn-brasil/querido-diario-apache-tika-server:${{ github.ref_name }}-amd64 \ | |
| ghcr.io/okfn-brasil/querido-diario-apache-tika-server:${{ github.ref_name }}-arm64 |