Skip to content

Commit 3ed434b

Browse files
committed
Fixed errors, updated versions, changed heroku stack
1 parent c9773bb commit 3ed434b

File tree

9 files changed

+34
-112
lines changed

9 files changed

+34
-112
lines changed

Dockerfile

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
# Inherit from Heroku's python stack
2-
FROM heroku/python:3
1+
# Inherit from Heroku's stack
2+
FROM heroku/heroku:16
3+
4+
ENV PYTHON_VERSION python-3.6.2
35

46
# Create working directories
5-
RUN mkdir -p /app/.heroku/opencv /tmp/opencv /tmp/leptonica /tmp/tesseract /tmp/python
7+
RUN mkdir -p /app/.profile.d /app/.heroku/opencv /tmp/opencv /tmp/leptonica /tmp/tesseract /tmp/python
68

79
# Copy files
810
ADD Install-OpenCV /tmp/opencv
911
ADD scripts/install_leptonica.sh /tmp/leptonica
1012
ADD scripts/install_tesseract.sh /tmp/tesseract
11-
ADD requirements.txt /tmp/python
13+
14+
RUN echo 'deb http://archive.ubuntu.com/ubuntu xenial multiverse' >> /etc/apt/sources.list && apt-get update
1215

1316
# Install OpenCV
1417
WORKDIR /tmp/opencv/Ubuntu
15-
RUN echo 'deb http://archive.ubuntu.com/ubuntu trusty multiverse' >> /etc/apt/sources.list && apt-get update
16-
RUN ./opencv_latest.sh
17-
RUN echo 'export PYTHONPATH=${PYTHONPATH:-/app/.heroku/opencv/lib/python3.5/site-packages}' > /app/.profile.d/opencv.sh
18-
RUN echo 'export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/app/.heroku/opencv/lib/pkgconfig' >> /app/.profile.d/opencv.sh
18+
RUN ./opencv_install.sh
1919

2020
# Install leptonica for tesseract
2121
WORKDIR /tmp/leptonica
@@ -25,16 +25,10 @@ RUN ./install_leptonica.sh
2525
WORKDIR /tmp/tesseract
2626
RUN ./install_tesseract.sh
2727

28-
# Prepare Python environment
29-
WORKDIR /tmp/python
30-
RUN /app/.heroku/python/bin/pip install -r requirements.txt
31-
3228
# Clean up
3329
RUN rm -rf /tmp/*
3430

3531
# Onbuild
3632
ONBUILD WORKDIR /app/user
37-
ONBUILD ADD requirements.txt /app/user/
38-
ONBUILD RUN /app/.heroku/python/bin/pip install -r requirements.txt
3933
ONBUILD ADD . /app/user/
4034

Install-OpenCV/Ubuntu/cmake-detect-python.patch

Lines changed: 0 additions & 17 deletions
This file was deleted.

Install-OpenCV/Ubuntu/opencv_install.sh

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,9 @@
55
# version - the version of OpenCV to be installed
66
# downloadfile - the name of the OpenCV download file
77
# dldir - the download directory (optional, if not specified creates an OpenCV directory in the working dir)
8-
if [[ -z "$version" ]]; then
9-
echo "Please define version before calling `basename $0` or use a wrapper like opencv_latest.sh"
10-
exit 1
11-
fi
12-
if [[ -z "$downloadfile" ]]; then
13-
echo "Please define downloadfile before calling `basename $0` or use a wrapper like opencv_latest.sh"
14-
exit 1
15-
fi
8+
version=3.3.1
9+
downloadfile=opencv-3.3.1.zip
10+
1611
if [[ -z "$dldir" ]]; then
1712
dldir=OpenCV
1813
fi
@@ -26,7 +21,8 @@ source dependencies.sh
2621
echo "--- Downloading OpenCV" $version
2722
mkdir -p $dldir
2823
cd $dldir
29-
wget -O $downloadfile http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/$version/$downloadfile/download
24+
25+
wget -O $downloadfile https://sourceforge.net/projects/opencvlibrary/files/opencv-unix/$version/$downloadfile/download
3026

3127
echo "--- Unarchiving OpenCV" $version
3228
echo $downloadfile | grep ".zip"
@@ -36,9 +32,6 @@ else
3632
tar -xvf $downloadfile
3733
fi
3834

39-
echo "--- Patching OpenCV" $version
40-
patch -p1 -d opencv-$version < ../cmake-detect-python.patch
41-
4235
echo "--- Installing OpenCV" $version
4336
cd opencv-$version
4437
mkdir build
@@ -52,18 +45,18 @@ cmake \
5245
-D BUILD_NEW_PYTHON_SUPPORT=ON \
5346
-D BUILD_opencv_python2=OFF \
5447
-D BUILD_opencv_python3=ON \
55-
-D INCLUDE_DIRS=${PYTHON_ROOT}/include/python3.5m \
48+
-D INCLUDE_DIRS=${PYTHON_ROOT}/include/python3.6m \
5649
-D INSTALL_C_EXAMPLES=OFF \
5750
-D INSTALL_PYTHON_EXAMPLES=OFF \
58-
-D PYTHON_INCLUDE_DIR=${PYTHON_ROOT}/include/python3.5m \
59-
-D PYTHON_INCLUDE_DIRS=${PYTHON_ROOT}/include/python3.5m \
60-
-D PYTHON_LIBRARIES=${PYTHON_ROOT}/lib/libpython3.5m.a \
61-
-D PYTHON3_INCLUDE_DIR=${PYTHON_ROOT}/include/python3.5m \
62-
-D PYTHON3_INCLUDE_DIRS=${PYTHON_ROOT}/include/python3.5m \
51+
-D PYTHON_INCLUDE_DIR=${PYTHON_ROOT}/include/python3.6m \
52+
-D PYTHON_INCLUDE_DIRS=${PYTHON_ROOT}/include/python3.6m \
53+
-D PYTHON_LIBRARIES=${PYTHON_ROOT}/lib/libpython3.6m.a \
54+
-D PYTHON3_INCLUDE_DIR=${PYTHON_ROOT}/include/python3.6m \
55+
-D PYTHON3_INCLUDE_DIRS=${PYTHON_ROOT}/include/python3.6m \
6356
-D PYTHON3_EXECUTABLE=${PYTHON_ROOT}/bin/python \
6457
-D PYTHON3_LIBRARY=/usr/lib/x86_64-linux-gnu/libpython3.4m.so \
65-
-D PYTHON3_LIBRARIES=${PYTHON_ROOT}/lib/libpython3.5m.a \
66-
-D PYTHON3_PACKAGES_PATH=${PYTHON_ROOT}/lib/python3.5/site-packages \
58+
-D PYTHON3_LIBRARIES=${PYTHON_ROOT}/lib/libpython3.6m.a \
59+
-D PYTHON3_PACKAGES_PATH=${PYTHON_ROOT}/lib/python3.6/site-packages \
6760
-D WITH_1394=OFF \
6861
-D WITH_FFMPEG=OFF \
6962
-D WITH_GSTREAMER=OFF \

Install-OpenCV/Ubuntu/opencv_latest.sh

Lines changed: 0 additions & 6 deletions
This file was deleted.

Install-OpenCV/get_latest_version_download_file.sh

Lines changed: 0 additions & 19 deletions
This file was deleted.

README.md

Lines changed: 10 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,16 @@
11
# Docker image for OCR and OpenCV service with Python3 on Heroku
22

3-
This docker image has Python3, OpenCV and Tesseract features for Heroku.
4-
5-
## Docker Hub
6-
7-
- [supistar/docker-heroku-python3-opencv-tesseract](https://hub.docker.com/r/supistar/docker-heroku-python3-opencv-tesseract/)
3+
This docker image is based on heroku:16 stack and has Python3, OpenCV and Tesseract features for Heroku.
4+
Tesseract will be updated to v.4 when stable.
85

96
## Versions
10-
- Python3: 3.5.1 (based heroku/python:3 docker image)
11-
- OpenCV: 3.1.0
12-
- Tesseract: 3.04.01
13-
- Tessdata: 3.04.00
14-
- Leptonica: 1.73
15-
16-
## How to use this docker image
17-
18-
1. Include this image by `FROM` command
19-
2. Place your Python app/wsgi `requirements.txt` file on project root.
20-
3. Run your app/wsgi application by `CMD` command
21-
22-
Here is one of Dockerfile sample:
23-
```
24-
# Base image
25-
FROM supistar/docker-heroku-python3-opencv-tesseract
26-
27-
# Add code
28-
ADD ./webapp /app/user/webapp/
29-
30-
# Run application
31-
WORKDIR /app/user/webapp
32-
CMD gunicorn --bind 0.0.0.0:$PORT main:app --log-file -
33-
```
7+
- Python3: 3.6.2
8+
- OpenCV: 3.3.1
9+
- Tesseract: 3.05.01
10+
- Tessdata: 3.05.01
11+
- Leptonica: 1.74.4
3412

35-
## References
36-
- [sugyan/docker-heroku-python-opencv](https://github.com/sugyan/docker-heroku-python-opencv)
37-
- [hideyuki/docker-heroku-nodejs-opencv-tesseract](https://github.com/hideyuki/docker-heroku-nodejs-opencv-tesseract)
13+
## Forked from
14+
- [supistar/docker-heroku-python3-opencv-tesseract]
3815

16+
I fixed some stuff that didn't work for me, switched to a newer Heroku stack and updated all the packages above to the latest versions.

requirements.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

scripts/install_leptonica.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/sh
22

33
# Variables
4-
VERSION=1.73
4+
VERSION=1.74.4
55
NAME=leptonica-${VERSION}
66
PREFIX=/app/.heroku/leptonica
77
PROFILE=/app/.profile.d/leptonica.sh

scripts/install_tesseract.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#!/bin/sh
22

33
# Variables
4-
OCR_VERSION=3.04.01
5-
DATA_VERSION=3.04.00
4+
OCR_VERSION=3.05.01
5+
DATA_VERSION=3.05.01
66
OCR_NAME=tesseract-${OCR_VERSION}
77
DATA_NAME=tessdata-${DATA_VERSION}
88
OCR_PREFIX=/app/.heroku/tesseract

0 commit comments

Comments
 (0)