Reputation: 31
I'm doing a docker image with Python 2.7 Alpine and scrapy to export my script towards my team.
This is my dockerfile:
FROM python:2.7-alpine
WORKDIR /usr/src/app
RUN python -m pip install parse pyOpenSSL scrapy scrapy-xlsx
COPY scriptv1/ .
And when I docker build -t python_space .
it goes like this :
At first I thought It was about cryptography not finding libssl-dev and that's why I'm doing "python -m pip install [...] pyOpenSSL [...] ".
I have no leads about what's going wrong :/.
Thanks for reading !
EDIT : I added RUN apk add build-base in order to build with gcc, different error pops out.
Upvotes: 0
Views: 1389
Reputation: 14369
This Dockerfile
will build an image in two stages, keeping the build dependencies in a throw-away image:
FROM library/python:2.7-alpine AS build
RUN apk add gcc musl-dev libffi-dev libressl-dev
RUN mkdir /wheels
WORKDIR /wheels
RUN pip wheel cryptography==2.8
FROM library/python:2.7-alpine
RUN apk add libressl
COPY --from=build /wheels /wheels
RUN pip install /wheels/*.whl
The resulting image is 93 MB in size.
You might want to adapt it to your exact packages and build dependencies.
In your case adding your own lines to the end of the Dockerfile
should be enough.
Upvotes: 3
Reputation: 169075
A non-alpine Dockerfile using python:2.7-slim
works fine, since it can use manylinux wheels.
FROM python:2.7-slim
RUN python -m pip install parse pyOpenSSL scrapy scrapy-xlsx
$ docker build .
Sending build context to Docker daemon 2.048kB
Step 1/2 : FROM python:2.7-slim
---> 426ba9523d99
Step 2/2 : RUN python -m pip install parse pyOpenSSL scrapy scrapy-xlsx
---> Running in 853a571c7a66
# ... snip ...
Successfully installed Automat-20.2.0 PyDispatcher-2.0.5 PyHamcrest-1.10.1 Twisted-19.10.0 attrs-19.3.0 cffi-1.14.0 constantly-15.1.0 cryptography-2.8 cssselect-1.1.0 enum34-1.1.9 et-xmlfile-1.0.1 functools32-3.2.3.post2 hyperlink-19.0.0 idna-2.9 incremental-17.5.0 ipaddress-1.0.23 jdcal-1.4.1 lxml-4.5.0 openpyxl-2.6.4 parse-1.15.0 parsel-1.5.2 protego-0.1.16 pyOpenSSL-19.1.0 pyasn1-0.4.8 pyasn1-modules-0.2.8 pycparser-2.19 queuelib-1.5.0 scrapy-1.8.0 scrapy-xlsx-0.1.1 service-identity-18.1.0 six-1.14.0 w3lib-1.21.0 zope.interface-4.7.1
The resulting image is 232MB.
Upvotes: 1