Skip to content

fix: corrige build do Dockerfile_apache_tika #13

fix: corrige build do Dockerfile_apache_tika

fix: corrige build do Dockerfile_apache_tika #13

on:
push:
branches:
- main
paths:
- 'Dockerfile_apache_tika'
- '.github/workflows/build_apache_tika.yaml'
tags:
- "v*"
issue_comment:
types: [created]
workflow_dispatch:
inputs:
tika_version:
description: 'Apache Tika version (e.g. 3.2.2)'
required: false
default: '3.2.2'
name: Build 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
if: |
(github.event_name != 'issue_comment') ||
(github.event.issue.pull_request != null && contains(github.event.comment.body, 'cicd/build'))
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@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
with:
ref: ${{ github.event_name == 'issue_comment' && format('refs/pull/{0}/head', github.event.issue.number) || github.ref }}
- name: Free up disk space
run: ./.github/scripts/free_disk_space.sh
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
with:
driver-opts: |
image=moby/buildkit:v0.12.5
- name: Build Apache Tika test image for ${{ matrix.platform }}
uses: docker/build-push-action@ca052bb54ab0790a636c9b5f226502c73d547a25 # v5.4.0
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 }},ignore-error=true
build-args: |
TIKA_VERSION=${{ inputs.tika_version || '3.2.2' }}
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@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
with:
ref: ${{ github.event_name == 'issue_comment' && format('refs/pull/{0}/head', github.event.issue.number) || github.ref }}
- name: Free up disk space
run: ./.github/scripts/free_disk_space.sh
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
with:
driver-opts: |
image=moby/buildkit:v0.12.5
- name: Login to GitHub Container Registry
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3.7.0
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Generate build metadata
id: meta
run: |
echo "build_date=$(date -u +"%Y-%m-%dT%H:%M:%SZ")" >> $GITHUB_OUTPUT
echo "vcs_ref=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
echo "version=$(git describe --tags --always 2>/dev/null || echo 'latest')" >> $GITHUB_OUTPUT
- name: Build and push Apache Tika development container image
if: ${{ startsWith(github.ref, 'refs/heads/') || github.event_name == 'issue_comment' }}
uses: docker/build-push-action@ca052bb54ab0790a636c9b5f226502c73d547a25 # v5.4.0
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 }},ignore-error=true
build-args: |
TIKA_VERSION=${{ inputs.tika_version || '3.2.2' }}
BUILD_DATE=${{ steps.meta.outputs.build_date }}
VCS_REF=${{ steps.meta.outputs.vcs_ref }}
tags: |
ghcr.io/${{ github.repository_owner }}/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@ca052bb54ab0790a636c9b5f226502c73d547a25 # v5.4.0
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 }},ignore-error=true
build-args: |
TIKA_VERSION=${{ inputs.tika_version || '3.2.2' }}
BUILD_DATE=${{ steps.meta.outputs.build_date }}
VCS_REF=${{ steps.meta.outputs.vcs_ref }}
tags: |
ghcr.io/${{ github.repository_owner }}/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@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
- name: Login to GitHub Container Registry
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3.7.0
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Verify single-arch images availability (branch/PR)
if: ${{ startsWith(github.ref, 'refs/heads/') || github.event_name == 'issue_comment' }}
run: |
IMAGE="ghcr.io/${{ github.repository_owner }}/querido-diario-apache-tika-server"
for tag in latest-amd64 latest-arm64; do
for i in {1..20}; do
if docker buildx imagetools inspect $IMAGE:$tag > /dev/null 2>&1; then
echo "Found $IMAGE:$tag";
break;
fi
echo "Waiting for $IMAGE:$tag to be available ($i/20)...";
sleep 3;
done
done
- name: Create and push Apache Tika development manifest
if: ${{ startsWith(github.ref, 'refs/heads/') || github.event_name == 'issue_comment' }}
run: |
IMAGE="ghcr.io/${{ github.repository_owner }}/querido-diario-apache-tika-server"
docker buildx imagetools create \
-t $IMAGE:latest \
$IMAGE:latest-amd64 \
$IMAGE:latest-arm64
- name: Verify single-arch images availability (tag)
if: ${{ startsWith(github.ref, 'refs/tags/') }}
run: |
IMAGE="ghcr.io/${{ github.repository_owner }}/querido-diario-apache-tika-server"
for arch in amd64 arm64; do
for i in {1..20}; do
if docker buildx imagetools inspect $IMAGE:${{ github.ref_name }}-$arch > /dev/null 2>&1; then
echo "Found $IMAGE:${{ github.ref_name }}-$arch";
break;
fi
echo "Waiting for $IMAGE:${{ 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: |
IMAGE="ghcr.io/${{ github.repository_owner }}/querido-diario-apache-tika-server"
docker buildx imagetools create \
-t $IMAGE:${{ github.ref_name }} \
$IMAGE:${{ github.ref_name }}-amd64 \
$IMAGE:${{ github.ref_name }}-arm64