Skip to content

Commit

Permalink
Merge pull request #102 from sakuli/feature/(sakuli/sakuli-ocr#7)/add…
Browse files Browse the repository at this point in the history
…-ocr-to-docker

Feature/(sakuli/sakuli ocr#7)/add ocr to docker
  • Loading branch information
svettwer authored Dec 18, 2020
2 parents ee42c7d + 85e9986 commit 4e4d7ab
Show file tree
Hide file tree
Showing 13 changed files with 82 additions and 7 deletions.
16 changes: 16 additions & 0 deletions .test/e2e/e2e-ocr/ocr/ocr.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
(async () => {
const testCase = new TestCase("OCR");
const url = "https://sakuli.io/e2e-pages/sandbox/#";
try {
await testCase.startStep("Navigate to website");
await _navigateTo(url);
await _wait(2000);

await testCase.startStep("find 'element in one place'");
await _getRegionByText("element in one place").highlight(1);
} catch (e) {
await testCase.handleException(e);
} finally {
await testCase.saveResult();
}
})();
17 changes: 17 additions & 0 deletions .test/e2e/e2e-ocr/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "e2e-ocr",
"version": "2.3.0",
"description": "An OCR test suite",
"private": true,
"contributors": [
"Tim Keiner <tim.keiner@consol.de>",
"Simon Hofmann <simon.hofmann@consol.de>",
"Sven Hettwer <sven.hettwer@consol.de>",
"Cliff Le Van <cliff.le.van@consol.de>"
],
"homepage": "https://github.com/sakuli/sakuli#readme",
"scripts": {
"test": "sakuli run .",
"test:debug": "node --inspect node_modules/@sakuli/cli/dist/index run ."
}
}
4 changes: 4 additions & 0 deletions .test/e2e/e2e-ocr/testsuite.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
testsuite.id=ocr
testsuite.browser=chrome
#log.level=debug
selenium.chrome.arguments=--incognito --disable-dev-shm-usage --no-sandbox
1 change: 1 addition & 0 deletions .test/e2e/e2e-ocr/testsuite.suite
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ocr/ocr.js https://sakuli.io
13 changes: 13 additions & 0 deletions .test/goss.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ package:
installed: true
dnsutils:
installed: true
tesseract:
installed: true
port:
tcp:5901:
listening: true
Expand All @@ -86,3 +88,14 @@ command:
exec: "echo ${LOG_MODE}"
stdout:
- "/^ci$/"
tesseract-languages:
exit-status: 0
exec: "tesseract --list-langs"
stdout:
- "deu"
- "eng"
tesseract-version:
exit-status: 0
exec: "tesseract -v"
stdout:
- "tesseract 4.1.1"
8 changes: 8 additions & 0 deletions .test/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,11 @@ docker run \
--shm-size=2G \
taconsol/sakuli:${1:-latest}

# OCR run
docker run \
--rm \
-e SAKULI_LICENSE_KEY=${SAKULI_LICENSE_KEY} \
-e SAKULI_TEST_SUITE=/sakuli-project/e2e-ocr \
-v $(pwd)/e2e:/sakuli-project \
--shm-size=2G \
taconsol/sakuli:${1:-latest}
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ All notable changes to this project will be documented in this file.
- Maintenance: Use node 14 in container [(#82)](https://github.com/sakuli/sakuli-docker/issues/82)
- Feature: Enable package installation [(#48)](https://github.com/sakuli/sakuli-docker/issues/48)
- Enhancement: Link log files instead of copying them [(#98)](https://github.com/sakuli/sakuli-docker/issues/98)
- Feature: Add ocr module to docker [(sakuli/sakuli-ocr#7)](https://github.com/sakuli/sakuli-ocr/issues/7)

## v2.4.0-2

Expand Down
20 changes: 17 additions & 3 deletions Dockerfile.sakuli-base
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ ENV REFRESHED_AT=${BUILD_DATE} \
VNC_RESOLUTION=1280x1024 \
VNC_PW=vncpassword \
VNC_VIEW_ONLY=false \
IMG=taconsol/sakuli-base
IMG=taconsol/sakuli-base \
TESSDATA_PREFIX=/usr/local/share/tessdata

EXPOSE $VNC_PORT $NO_VNC_PORT

Expand All @@ -37,6 +38,9 @@ WORKDIR $HOME
COPY ./src/common/install/ $INST_SCRIPTS/
RUN find $INST_SCRIPTS -name '*.sh' -exec chmod a+x {} +

### Copy tesseract
COPY ./src/tesseract /tmp/tesseract

### Install required packages and add configuration
RUN apt-get update && \
apt-get install -y \
Expand Down Expand Up @@ -68,7 +72,13 @@ RUN apt-get update && \
curl \
iputils-ping \
iputils-tracepath \
dnsutils && \
dnsutils \
libleptonica-dev \
libpng-dev \
libjpeg8-dev \
libtiff5-dev \
zlib1g-dev \
libtool && \
apt-get clean -y && \
apt-get autoremove -y && \
rm -rf /var/lib/apt/lists/* /var/cache/apt/* && \
Expand All @@ -84,7 +94,11 @@ RUN apt-get update && \
chmod +x -v $NO_VNC_HOME/utils/*.sh && \
ln -s $NO_VNC_HOME/vnc_lite.html $NO_VNC_HOME/index.html && \
ln -s /usr/bin/chromium-browser /usr/bin/google-chrome && \
echo "CHROMIUM_FLAGS='--no-sandbox --user-data-dir'" > $HOME/.chromium-browser.init
echo "CHROMIUM_FLAGS='--no-sandbox --user-data-dir'" > $HOME/.chromium-browser.init && \
dpkg -i /tmp/tesseract/tesseract_4.1.1-1_amd64.deb && \
ldconfig && \
cp /tmp/tesseract/*traineddata /usr/local/share/tessdata && \
rm -rf /tmp/tesseract

COPY ./src/common/wm/ $HOME/
COPY ./src/common/config/openbox /etc/xdg/openbox
Expand Down
6 changes: 2 additions & 4 deletions run.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#!/usr/bin/env bash

docker run \
--rm \
-it \
-e SAKULI_LICENSE_KEY=${SAKULI_LICENSE_KEY} \
-p 5902:5901 \
-p 6902:6901 \
-p 5901:5901 \
-p 6901:6901 \
taconsol/sakuli
3 changes: 3 additions & 0 deletions src/sakuli/sakuli.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ do
npm i -g -E @sakuli/forwarder-$fwd@$1
done

echo "Installing Sakuli OCR v$1"
npm i -g -E @sakuli/ocr@$1

echo "Installing TypeScript v3.8.3"
npm i -g -E typescript@3.8.3

Expand Down
Binary file added src/tesseract/deu.traineddata
Binary file not shown.
Binary file added src/tesseract/eng.traineddata
Binary file not shown.
Binary file added src/tesseract/tesseract_4.1.1-1_amd64.deb
Binary file not shown.

0 comments on commit 4e4d7ab

Please sign in to comment.