Skip to content

Commit 4e43071

Browse files
committed
actually adding tesseract
1 parent c7efbd0 commit 4e43071

3 files changed

Lines changed: 23 additions & 8 deletions

File tree

‎Dockerfile‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ RUN apt-get update -y && apt-get upgrade -y \
99
gcc \
1010
libpq-dev \
1111
libxml2-dev \
12-
python3-dev \
12+
python3-dev \
1313
postgresql-client \
1414
&& rm -rf /var/lib/apt/lists/
1515

@@ -45,3 +45,17 @@ RUN pip install --no-cache-dir -e .
4545
EXPOSE 8000
4646

4747
CMD ["gunicorn", "-w", "4", "-b", "0.0.0.0", "quiabo:app"]
48+
49+
FROM app AS worker
50+
51+
USER root
52+
53+
RUN apt-get update -y \
54+
&& apt-get install -y --no-install-recommends \
55+
tesseract-ocr \
56+
tesseract-ocr-eng \
57+
tesseract-ocr-spa \
58+
tesseract-ocr-deu \
59+
&& rm -rf /var/lib/apt/lists/*
60+
61+
USER $APP_USER

‎docker-compose.yml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ services:
5252
worker:
5353
build:
5454
context: .
55+
target: worker
5556
depends_on:
5657
db:
5758
condition: service_healthy

‎test/unit/test_tasks.py‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,25 @@ def test_shared_task_delay_delegates_to_apply_async(monkeypatch):
1717
apply_async = Mock(return_value="queued")
1818
monkeypatch.setattr(run_tesseract_job, "apply_async", apply_async)
1919

20-
result = run_tesseract_job.delay("filelist.txt", ["eng", "spa"], "output.pdf")
20+
result = run_tesseract_job.delay("filelist.txt", ["eng", "spa"], "output")
2121

2222
assert result == "queued"
2323
apply_async.assert_called_once_with(
24-
("filelist.txt", ["eng", "spa"], "output.pdf"),
24+
("filelist.txt", ["eng", "spa"], "output"),
2525
{},
2626
)
2727

2828

29-
def test_run_tesseract_job_updates_state_and_returns_command(monkeypatch):
29+
def test_run_tesseract_job_updates_state_and_runs_tesseract(monkeypatch):
3030
update_state = Mock()
31+
run = Mock()
3132
monkeypatch.setattr(run_tesseract_job, "update_state", update_state)
33+
monkeypatch.setattr("quiabo.tasks.subprocess.run", run)
3234

3335
result = run_tesseract_job.run(
3436
"files.txt",
3537
["eng", "spa"],
36-
"output.pdf",
38+
"output",
3739
)
3840

3941
update_state.assert_called_once_with(
@@ -44,6 +46,4 @@ def test_run_tesseract_job_updates_state_and_returns_command(monkeypatch):
4446
"output": "output.pdf",
4547
},
4648
)
47-
assert result == {
48-
"tesseract_command": ("tesseract -l eng,spa files.txt output.pdf pdf")
49-
}
49+
assert result == {"output": ("output.pdf")}

0 commit comments

Comments
 (0)