Rework Dockerfile, setup.py to work with wheels for better cache use

This commit is contained in:
James R. Barlow 2015-08-19 13:43:32 -07:00
parent c132e091e1
commit 8e2d690cb0
4 changed files with 24 additions and 16 deletions

View File

@ -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
View File

@ -0,0 +1,4 @@
ruffus>=2.6.3
Pillow>=2.4.0
reportlab>=3.1.44
PyPDF2>=1.25.1

View File

@ -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
View File

@ -0,0 +1,2 @@
img2pdf>=0.1.5
pytest>=2.7.2