Skip to content

Commit bcfc0ea

Browse files
nddipiazzaCopilot
andauthored
TIKA-4703: Fix tika-grpc Docker image missing runtime dependencies (#2790)
* TIKA-4703: Fix tika-grpc Docker image missing runtime dependencies Use 'mvn dependency:copy-dependencies' to populate the lib/ directory of runtime jars that the MANIFEST.MF Class-Path entries reference. Without this the image only contained the thin jar and Java threw: NoClassDefFoundError: io/grpc/BindableService The jar's MANIFEST.MF (set by maven-jar-plugin classpathPrefix=lib/) expects dependencies at lib/ relative to the jar, i.e. /tika/libs/lib/ in the image. Running dependency:copy-dependencies into that path after the main build ensures all runtime deps are present. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * TIKA-4703: Rename lib dir to tika-grpc, consolidate dep step, add grpc smoke test - Rename classpathPrefix from lib/ to tika-grpc/ in maven-jar-plugin so MANIFEST.MF Class-Path matches the actual directory layout in the image - Update docker-snapshot.yml and docker-release.yml: rename libs/lib -> libs/tika-grpc, consolidate separate 'Collect' + 'Prepare' steps into a single Prepare step - Add smoke test to docker-snapshot.yml: builds single-arch image with --load, starts container, polls for 'Server started' log line, fails CI if not seen within 30s Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * TIKA-4703: Add smoke tests for tika-server minimal and full Docker images - Build single-arch (amd64) image with --load before each multi-arch push - Poll for 'Started Apache Tika server' log line for up to 40 seconds - Fail CI job if server does not start; dump logs on failure - tika-server has no missing-deps issue (bin.tgz already bundles lib/) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * TIKA-4703: Fix assembly.xml dep dir and use trap-based cleanup in smoke tests - Update assembly.xml outputDirectory from lib/ to tika-grpc/ to match classpathPrefix in pom.xml; without this the binary zip would have deps under lib/ while MANIFEST.MF Class-Path references tika-grpc/*.jar - Replace bare docker stop/exit in all three smoke test steps with a trap cleanup function using docker rm -f; this prevents bash -e from failing on a stop of an already-exited container and ensures logs are always collected on failure Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent cb20b84 commit bcfc0ea

4 files changed

Lines changed: 108 additions & 4 deletions

File tree

.github/workflows/docker-release.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,12 @@ jobs:
112112
TIKA_VERSION="${{ steps.version.outputs.tag }}"
113113
OUT_DIR=target/tika-grpc-docker
114114
115-
mkdir -p "${OUT_DIR}/libs" "${OUT_DIR}/plugins" "${OUT_DIR}/config" "${OUT_DIR}/bin"
115+
mkdir -p "${OUT_DIR}/libs/tika-grpc" "${OUT_DIR}/plugins" "${OUT_DIR}/config" "${OUT_DIR}/bin"
116116
117117
cp "tika-grpc/target/tika-grpc-${TIKA_VERSION}.jar" "${OUT_DIR}/libs/"
118+
mvn -pl tika-grpc dependency:copy-dependencies \
119+
-DoutputDirectory="${PWD}/${OUT_DIR}/libs/tika-grpc" \
120+
-DincludeScope=runtime -q -B
118121
119122
# Copy tika-pipes plugin zip files
120123
for dir in tika-pipes/tika-pipes-plugins/*/; do

.github/workflows/docker-snapshot.yml

Lines changed: 102 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,38 @@ jobs:
6969
tar xzf "tika-server/tika-server-standard/target/tika-server-standard-${TIKA_VERSION}-bin.tgz" -C "${OUT_DIR}/tika-server"
7070
cp "tika-server/docker-build/minimal/Dockerfile.snapshot" "${OUT_DIR}/Dockerfile"
7171
72+
- name: Build tika-server minimal image for smoke test
73+
uses: docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8 # v6.19.2
74+
with:
75+
context: target/tika-server-minimal-docker
76+
platforms: linux/amd64
77+
load: true
78+
build-args: |
79+
TIKA_VERSION=${{ steps.version.outputs.tika_version }}
80+
tags: tika-server-minimal-smoke:ci
81+
82+
- name: Smoke test tika-server minimal image
83+
run: |
84+
cleanup() {
85+
status=$?
86+
if [ "$status" -ne 0 ]; then
87+
docker logs tika-server-minimal-smoke || true
88+
fi
89+
docker rm -f tika-server-minimal-smoke >/dev/null 2>&1 || true
90+
exit "$status"
91+
}
92+
trap cleanup EXIT
93+
docker run -d --name tika-server-minimal-smoke -p 9998:9998 tika-server-minimal-smoke:ci
94+
for i in $(seq 1 20); do
95+
if docker logs tika-server-minimal-smoke 2>&1 | grep -q "Started Apache Tika server"; then
96+
echo "tika-server minimal started successfully"
97+
exit 0
98+
fi
99+
sleep 2
100+
done
101+
echo "ERROR: tika-server minimal did not start within 40 seconds"
102+
exit 1
103+
72104
- name: Build and push tika-server minimal snapshot
73105
uses: docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8 # v6.19.2
74106
with:
@@ -89,6 +121,38 @@ jobs:
89121
tar xzf "tika-server/tika-server-standard/target/tika-server-standard-${TIKA_VERSION}-bin.tgz" -C "${OUT_DIR}/tika-server"
90122
cp "tika-server/docker-build/full/Dockerfile.snapshot" "${OUT_DIR}/Dockerfile"
91123
124+
- name: Build tika-server full image for smoke test
125+
uses: docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8 # v6.19.2
126+
with:
127+
context: target/tika-server-full-docker
128+
platforms: linux/amd64
129+
load: true
130+
build-args: |
131+
TIKA_VERSION=${{ steps.version.outputs.tika_version }}
132+
tags: tika-server-full-smoke:ci
133+
134+
- name: Smoke test tika-server full image
135+
run: |
136+
cleanup() {
137+
status=$?
138+
if [ "$status" -ne 0 ]; then
139+
docker logs tika-server-full-smoke || true
140+
fi
141+
docker rm -f tika-server-full-smoke >/dev/null 2>&1 || true
142+
exit "$status"
143+
}
144+
trap cleanup EXIT
145+
docker run -d --name tika-server-full-smoke -p 9999:9998 tika-server-full-smoke:ci
146+
for i in $(seq 1 20); do
147+
if docker logs tika-server-full-smoke 2>&1 | grep -q "Started Apache Tika server"; then
148+
echo "tika-server full started successfully"
149+
exit 0
150+
fi
151+
sleep 2
152+
done
153+
echo "ERROR: tika-server full did not start within 40 seconds"
154+
exit 1
155+
92156
- name: Build and push tika-server full snapshot
93157
uses: docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8 # v6.19.2
94158
with:
@@ -106,9 +170,12 @@ jobs:
106170
TIKA_VERSION="${{ steps.version.outputs.tika_version }}"
107171
OUT_DIR=target/tika-grpc-docker
108172
109-
mkdir -p "${OUT_DIR}/libs" "${OUT_DIR}/plugins" "${OUT_DIR}/config" "${OUT_DIR}/bin"
173+
mkdir -p "${OUT_DIR}/libs/tika-grpc" "${OUT_DIR}/plugins" "${OUT_DIR}/config" "${OUT_DIR}/bin"
110174
111175
cp "tika-grpc/target/tika-grpc-${TIKA_VERSION}.jar" "${OUT_DIR}/libs/"
176+
mvn -pl tika-grpc dependency:copy-dependencies \
177+
-DoutputDirectory="${PWD}/${OUT_DIR}/libs/tika-grpc" \
178+
-DincludeScope=runtime -q -B
112179
113180
# Copy tika-pipes plugin zip files
114181
for dir in tika-pipes/tika-pipes-plugins/*/; do
@@ -135,6 +202,40 @@ jobs:
135202
cp "tika-grpc/docker-build/start-tika-grpc.sh" "${OUT_DIR}/bin/"
136203
cp "tika-grpc/docker-build/Dockerfile" "${OUT_DIR}/Dockerfile"
137204
205+
- name: Build tika-grpc image for smoke test
206+
uses: docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8 # v6.19.2
207+
with:
208+
context: target/tika-grpc-docker
209+
platforms: linux/amd64
210+
load: true
211+
build-args: |
212+
VERSION=${{ steps.version.outputs.tika_version }}
213+
tags: tika-grpc-smoke:ci
214+
215+
- name: Smoke test tika-grpc image
216+
run: |
217+
cleanup() {
218+
status=$?
219+
if [ "$status" -ne 0 ]; then
220+
docker logs tika-grpc-smoke || true
221+
docker ps -a --filter "name=^tika-grpc-smoke$" || true
222+
docker inspect -f '{{.State.ExitCode}}' tika-grpc-smoke || true
223+
fi
224+
docker rm -f tika-grpc-smoke >/dev/null 2>&1 || true
225+
exit "$status"
226+
}
227+
trap cleanup EXIT
228+
docker run -d --name tika-grpc-smoke -p 9090:9090 tika-grpc-smoke:ci
229+
for i in $(seq 1 15); do
230+
if docker logs tika-grpc-smoke 2>&1 | grep -q "Server started, listening on"; then
231+
echo "tika-grpc started successfully"
232+
exit 0
233+
fi
234+
sleep 2
235+
done
236+
echo "ERROR: tika-grpc did not start within 30 seconds"
237+
exit 1
238+
138239
- name: Build and push tika-grpc snapshot
139240
uses: docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8 # v6.19.2
140241
with:

tika-grpc/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@
474474
<manifest>
475475
<mainClass>org.apache.tika.pipes.grpc.TikaGrpcServer</mainClass>
476476
<addClasspath>true</addClasspath>
477-
<classpathPrefix>lib/</classpathPrefix>
477+
<classpathPrefix>tika-grpc/</classpathPrefix>
478478
</manifest>
479479
</archive>
480480
</configuration>

tika-grpc/src/main/assembly/assembly.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
<dependencySets>
2727
<dependencySet>
28-
<outputDirectory>lib</outputDirectory>
28+
<outputDirectory>tika-grpc</outputDirectory>
2929
<useProjectArtifact>false</useProjectArtifact>
3030
<unpack>false</unpack>
3131
<scope>runtime</scope>

0 commit comments

Comments
 (0)