Search code examples
pythondockergeventalpine-linux

Build python's gevent in outer Docker image


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 <???>

Solution

  • 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