Skip to content

Commit 7b6f7e6

Browse files
committed
added dockerfile
1 parent 787fa9f commit 7b6f7e6

File tree

3 files changed

+69
-3
lines changed

3 files changed

+69
-3
lines changed

Dockerfile

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# start with a base image
2+
FROM ubuntu:14.04
3+
4+
# install dependencies
5+
RUN apt-get update
6+
RUN apt-get install -y autoconf automake libtool
7+
RUN apt-get install -y libpng12-dev
8+
RUN apt-get install -y libjpeg62-dev
9+
RUN apt-get install -y g++
10+
RUN apt-get install -y libtiff4-dev
11+
RUN apt-get install -y libopencv-dev libtesseract-dev
12+
RUN apt-get install -y git
13+
RUN apt-get install -y cmake
14+
RUN apt-get install -y build-essential
15+
RUN apt-get install -y libleptonica-dev
16+
RUN apt-get install -y liblog4cplus-dev
17+
RUN apt-get install -y libcurl3-dev
18+
RUN apt-get install -y python2.7-dev
19+
RUN apt-get install -y tk8.5 tcl8.5 tk8.5-dev tcl8.5-dev
20+
RUN apt-get build-dep -y python-imaging --fix-missing
21+
RUN apt-get install -y imagemagick
22+
RUN apt-get install -y wget
23+
RUN apt-get install -y python python-pip
24+
25+
# build leptonica
26+
RUN wget http://www.leptonica.org/source/leptonica-1.70.tar.gz
27+
RUN tar -zxvf leptonica-1.70.tar.gz
28+
WORKDIR leptonica-1.70/
29+
RUN ./autobuild
30+
RUN ./configure
31+
RUN make
32+
RUN make install
33+
RUN ldconfig
34+
WORKDIR /
35+
RUN ls
36+
37+
ADD requirements.txt /
38+
RUN pip install -r requirements.txt
39+
40+
# build tesseract
41+
RUN wget https://tesseract-ocr.googlecode.com/files/tesseract-ocr-3.02.02.tar.gz
42+
RUN tar -zxvf tesseract-ocr-3.02.02.tar.gz
43+
WORKDIR tesseract-ocr/
44+
RUN ./autogen.sh
45+
RUN ./configure
46+
RUN make
47+
RUN make install
48+
RUN ldconfig
49+
RUN cd ..
50+
51+
# download the relevant Tesseract English Language Packages
52+
RUN wget https://tesseract-ocr.googlecode.com/files/tesseract-ocr-3.02.eng.tar.gz
53+
RUN tar -xf tesseract-ocr-3.02.eng.tar.gz
54+
RUN sudo cp -r tesseract-ocr/tessdata /usr/local/share/
55+
56+
# update working directories
57+
ADD ./flask_server /flask_server
58+
WORKDIR /flask_server
59+
60+
EXPOSE 80
61+
CMD ["python", "app.py"]

_run.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ sudo apt-get build-dep -y python-imaging --fix-missing
2020
sudo apt-get install -y imagemagick
2121

2222

23-
# Building Leptonica
23+
# Build Leptonica
2424
wget http://www.leptonica.org/source/leptonica-1.70.tar.gz
2525
tar -zxvf leptonica-1.70.tar.gz
2626
cd leptonica-1.70/
@@ -31,7 +31,7 @@ sudo make install
3131
sudo ldconfig
3232

3333

34-
# Building Tesseract
34+
# Build Tesseract
3535
cd ..
3636
wget https://tesseract-ocr.googlecode.com/files/tesseract-ocr-3.02.02.tar.gz
3737
tar -zxvf tesseract-ocr-3.02.02.tar.gz

flask_server/app.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,15 @@
99
_VERSION = 1 # API version
1010

1111

12+
@app.route('/')
13+
def main():
14+
return "tesr"
15+
16+
1217
@app.route('/v{}/ocr'.format(_VERSION), methods=["POST"])
1318
def ocr():
1419
try:
15-
url = request.form['image_url']
20+
url = request.json['image_url']
1621
output = process_image(url)
1722
return jsonify({"output": output})
1823
except KeyError:

0 commit comments

Comments
 (0)