mirror of
https://github.com/ocrmypdf/OCRmyPDF.git
synced 2025-12-27 15:10:22 +00:00
Rework Dockerfile, setup.py to work with wheels for better cache use
This commit is contained in:
parent
c132e091e1
commit
8e2d690cb0
19
Dockerfile
19
Dockerfile
@ -13,6 +13,7 @@ RUN useradd docker \
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
bc \
|
||||
curl \
|
||||
wget \
|
||||
zlib1g-dev \
|
||||
libjpeg-dev \
|
||||
ghostscript \
|
||||
@ -23,13 +24,11 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
poppler-utils \
|
||||
python3 \
|
||||
python3-pip \
|
||||
python3-pil \
|
||||
python3-pytest \
|
||||
python3-reportlab
|
||||
python3-dev \
|
||||
gcc
|
||||
|
||||
|
||||
RUN apt-get install -y wget
|
||||
|
||||
# Ubuntu 14.04's ensurepip is broken, so it cannot create py3 virtual envs
|
||||
# Use elaborate workaround: create a venv without pip, activate that environment,
|
||||
# download a script to install pip into the environment
|
||||
@ -39,12 +38,20 @@ RUN python3 -m venv appenv --without-pip
|
||||
RUN . /appenv/bin/activate; \
|
||||
wget -O - -o /dev/null https://bootstrap.pypa.io/get-pip.py | python
|
||||
|
||||
RUN apt-get install -y gcc python3-dev
|
||||
COPY ./*requirements.txt /application/
|
||||
|
||||
# Build wheels separately so build is cached by Docker
|
||||
RUN . /appenv/bin/activate; \
|
||||
pip install wheel \
|
||||
&& pip wheel --wheel-dir=/wheelhouse -r /application/requirements.txt \
|
||||
&& pip wheel --wheel-dir=/wheelhouse -r /application/test_requirements.txt
|
||||
|
||||
COPY . /application/
|
||||
|
||||
# Install application using our built wheels
|
||||
RUN . /appenv/bin/activate; \
|
||||
pip install /application/.
|
||||
pip install --no-index --find-links=/wheelhouse /application \
|
||||
&& pip install --no-index --find-links=/wheelhouse -r /application/test_requirements.txt
|
||||
|
||||
USER docker
|
||||
WORKDIR /home/docker
|
||||
|
||||
4
requirements.txt
Normal file
4
requirements.txt
Normal file
@ -0,0 +1,4 @@
|
||||
ruffus>=2.6.3
|
||||
Pillow>=2.4.0
|
||||
reportlab>=3.1.44
|
||||
PyPDF2>=1.25.1
|
||||
15
setup.py
15
setup.py
@ -174,6 +174,9 @@ if 'upload' in sys.argv[1:]:
|
||||
print('Use twine to upload the package - setup.py upload is insecure')
|
||||
sys.exit(1)
|
||||
|
||||
install_requires = open('requirements.txt').read().splitlines()
|
||||
tests_require = open('test_requirements.txt').read().splitlines()
|
||||
|
||||
setup(
|
||||
name='ocrmypdf',
|
||||
version='3.0rc5', # also update: release notes, main.py
|
||||
@ -200,16 +203,8 @@ setup(
|
||||
"Topic :: Text Processing :: Indexing",
|
||||
"Topic :: Text Processing :: Linguistic",
|
||||
],
|
||||
install_requires=[
|
||||
'ruffus>=2.6.3',
|
||||
'Pillow>=2.4.0',
|
||||
'reportlab>=3.1.44',
|
||||
'PyPDF2>=1.25.1'
|
||||
],
|
||||
tests_require=[
|
||||
'img2pdf>=0.1.5',
|
||||
'pytest>=2.7.2'
|
||||
],
|
||||
install_requires=install_requires,
|
||||
tests_require=tests_require,
|
||||
entry_points={
|
||||
'console_scripts': [
|
||||
'ocrmypdf = ocrmypdf.main:run_pipeline'
|
||||
|
||||
2
test_requirements.txt
Normal file
2
test_requirements.txt
Normal file
@ -0,0 +1,2 @@
|
||||
img2pdf>=0.1.5
|
||||
pytest>=2.7.2
|
||||
Loading…
x
Reference in New Issue
Block a user