Search code examples
pythondockercompiler-errorsalpine-linuxorc

Failed to install pyorc on alpine docker container


Getting compilation error - which is dependent on ORC binaries.

In file included from src/_pyorc/_pyorc.cpp:1:
src/_pyorc/Reader.h:7:10: fatal error: 'orc/OrcFile.hh' file not found
#include "orc/OrcFile.hh"
         ^~~~~~~~~~~~~~~~
1 error generated.
error: command 'clang' failed with exit status 1

If I compile apache-orc separately then too, how can I give reference of it to PyOrc Pip Installation?

Anyone has any solution or idea how can we install pyorc package inside alpine container.

I'm having trouble with alpine image with ubuntu and normal python docker image its working well.

Docker Image: FROM python:3.7-alpine


Solution

  • I used Docker multi-stage builds:

    # Dockerfile
    
    FROM python:3.7.3
    WORKDIR /app
    RUN pip install pyorc -t .
    
    FROM python:3.7.3-alpine
    WORKDIR /app
    RUN apk add --no-cache --virtual .build-deps g++ musl-dev gcompat
    COPY --from=0 /app .
    

    and it seems working:

    $ docker build -t test .
    $ docker run -it --rm test python
    Python 3.7.3 (default, Jun 27 2019, 22:53:21)
    [GCC 8.3.0] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import pyorc
    >>>
    >>> with open("./new_data.orc", "wb") as data:
    ...     with pyorc.Writer(data, "struct<col0:int,col1:string>") as writer:
    ...         writer.write((1, "ORC from Python"))
    ...
    >>> from pathlib import Path
    >>> Path("./new_data.orc").read_bytes()
    b'ORC\x1d\x00\x00\n\x0c\n\x04\x00\x00\x.....'