-1

This dockerfile will obviously not work:

FROM python:3.7.0-alpine

RUN pip install gevent

since there is no compiler in alpine.

Is it possible to install it in a different docker image and then copy it to my image?

In other words, can i achieve that by replacing <???> with something?

FROM python:3.7.0-streach as base

RUN pip install gevent

FROM python:3.7.0-alpine

COPY --from=base <???>
Kazz
  • 585
  • 1
  • 6
  • 23

2 Answers2

4

For those finding this a year later, this should work:

FROM python:3.7.0-stretch as base

RUN apk add build-base
RUN mkdir /install
RUN pip install --install-option="--prefix=/install" gevent

FROM python:3.7.0-alpine

COPY --from=base /install /usr/local
Roger Collins
  • 1,188
  • 1
  • 8
  • 12
0

Alpine Linux has the build-base that provides a convenient way to install a compiler and other build tools. You'll want to install libffi-dev and other packages that provide headers as well.

Your intended approach to copy gevent from a Debian-based container to an Alpine-based one, will not work as the latter uses musl, not libc. Have a look at apk's --virtual option to easily un-/install build dependencies.

As far as I can tell, due to ABI changes gevent (or certain versions of it) do not compile against CPython 3.7 (yet).

funky-future
  • 3,716
  • 1
  • 30
  • 43