Skip to content

Commit 1161ea9

Browse files
authored
Merge pull request #1 from chenyme/copilot/create-github-workflow-dockerfile
feat: add Dockerfile and GitHub Actions workflow for Tika Chinese image
2 parents 2504f93 + af243d4 commit 1161ea9

4 files changed

Lines changed: 118 additions & 0 deletions

File tree

‎.github/workflows/docker-build.yml‎

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Build and Push Tika Chinese Image
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
tags:
8+
- "v*"
9+
pull_request:
10+
branches:
11+
- main
12+
13+
env:
14+
REGISTRY: ghcr.io
15+
IMAGE_NAME: ${{ github.repository }}
16+
17+
jobs:
18+
build-and-push:
19+
runs-on: ubuntu-latest
20+
permissions:
21+
contents: read
22+
packages: write
23+
24+
steps:
25+
- name: Checkout repository
26+
uses: actions/checkout@v4
27+
28+
- name: Set up Docker Buildx
29+
uses: docker/setup-buildx-action@v3
30+
31+
- name: Log in to GitHub Container Registry
32+
if: github.event_name != 'pull_request'
33+
uses: docker/login-action@v3
34+
with:
35+
registry: ${{ env.REGISTRY }}
36+
username: ${{ github.actor }}
37+
password: ${{ secrets.GITHUB_TOKEN }}
38+
39+
- name: Extract Docker metadata
40+
id: meta
41+
uses: docker/metadata-action@v5
42+
with:
43+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
44+
tags: |
45+
type=ref,event=tag
46+
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }}
47+
48+
- name: Build and push Docker image
49+
uses: docker/build-push-action@v6
50+
with:
51+
context: .
52+
push: ${{ github.event_name != 'pull_request' }}
53+
tags: ${{ steps.meta.outputs.tags }}
54+
labels: ${{ steps.meta.outputs.labels }}
55+
cache-from: type=gha
56+
cache-to: type=gha,mode=max

‎Dockerfile‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Base: Apache Tika full image (includes Tesseract OCR engine)
2+
# Pin to a specific version for reproducible builds
3+
FROM apache/tika:3.3.0.0-full
4+
5+
USER root
6+
7+
# Install simplified & traditional Chinese Tesseract language packs and common Chinese fonts
8+
RUN apt-get update && \
9+
apt-get install -y --no-install-recommends \
10+
tesseract-ocr-chi-sim \
11+
tesseract-ocr-chi-tra \
12+
fonts-noto-cjk \
13+
fonts-wqy-zenhei \
14+
fonts-wqy-microhei \
15+
&& rm -rf /var/lib/apt/lists/*
16+
17+
# Copy Tika configuration (enables Chinese Tesseract OCR)
18+
COPY tika-config.xml /tika-config.xml
19+
20+
# Switch back to the non-root tika user (UID 35002) defined in the base image
21+
USER 35002
22+
23+
CMD ["-c", "/tika-config.xml"]

‎README.md‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Tika Chinese Image
2+
3+
Apache Tika server with Simplified & Traditional Chinese OCR support (Tesseract) and common Chinese fonts, based on `apache/tika:3.3.0.0-full`.
4+
5+
## Pull the image
6+
7+
```bash
8+
docker pull ghcr.io/chenyme/tika:latest
9+
```
10+
11+
## Start the server
12+
13+
```bash
14+
docker run -d -p 9998:9998 ghcr.io/chenyme/tika:latest
15+
```
16+
17+
The container uses `-c /tika-config.xml` by default, which enables Tesseract OCR with Simplified Chinese (`chi_sim`), Traditional Chinese (`chi_tra`), and English (`eng`).
18+
19+
## Use the server
20+
21+
```bash
22+
# Parse a file
23+
curl -T /path/to/document.pdf http://localhost:9998/tika
24+
25+
# Check server status
26+
curl http://localhost:9998/tika
27+
```

‎tika-config.xml‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<properties>
3+
<parsers>
4+
<parser class="org.apache.tika.parser.DefaultParser"/>
5+
</parsers>
6+
<service name="org.apache.tika.parser.ocr.TesseractOCRConfig">
7+
<params>
8+
<param name="language" type="string">chi_sim+chi_tra+eng</param>
9+
<param name="timeout" type="int">300</param>
10+
</params>
11+
</service>
12+
</properties>

0 commit comments

Comments
 (0)