-
-
Notifications
You must be signed in to change notification settings - Fork 19
255 lines (230 loc) · 9.4 KB
/
build_apache_tika.yaml
File metadata and controls
255 lines (230 loc) · 9.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
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