Python: couchbase client

Created on 5 Nov 2018  路  5Comments  路  Source: docker-library/python

Hi, i've seen the issues https://github.com/docker-library/python/issues/60 & another one on gcc on alpine.

I'm trying to install couchbase client via docker. I've tried multiple ways including replicating part of the alpine code:

RUN apk add --no-cache --virtual .build-deps  \
        libcouchbase \
        bzip2-dev \
        coreutils \
        dpkg-dev dpkg \
        expat-dev \
        gcc \
        g++ \
        gdbm-dev \
        libc-dev \
        libffi-dev \
        linux-headers \
        make \
        ncurses-dev \
        openssl \
        openssl-dev \
        pax-utils \
        readline-dev \
        sqlite-dev \
        tcl-dev \
        tk \
        tk-dev \
        xz-dev \
        zlib-dev \
    && pip install couchbase \
    && apk del .build-deps 

but couchbase client still fails due to gcc.

error:

src/exceptions.c -o build/temp.linux-x86_64-3.6/src/exceptions.o
    In file included from src/exceptions.c:17:0:
    src/pycbc.h:193:36: fatal error: libcouchbase/couchbase.h: No such file or directory
     #include <libcouchbase/couchbase.h>
                                        ^
    compilation terminated.
    error: command 'gcc' failed with exit status 1

Is there a recommended base python that would have this fixed even if size is bigger?

Thank you for your help

question

Most helpful comment

@ElianoMarques this isn't really an issue with the Docker images, as you'll need to have the right headers/libraries to build the client on any platform.

Anyway, if you want something quick, the simplest I can come up with for Alpine is:

FROM python:alpine
RUN set -ex; \
    apk add --no-cache --virtual .buildDeps gcc libcouchbase-dev; \
    apk add --no-cache libcouchbase; \
    pip install --no-cache 'couchbase<2.4.0'; \
    apk del .buildDeps

You have to use version < 2.4.0 due to this issue. For newer versions and other platforms, as @tao12345666333 said, you should consult the Couchbase docs or ask in a Couchbase forum.

All 5 comments

Maybe you need take a look at the official documents.. Good luck!

@ElianoMarques this isn't really an issue with the Docker images, as you'll need to have the right headers/libraries to build the client on any platform.

Anyway, if you want something quick, the simplest I can come up with for Alpine is:

FROM python:alpine
RUN set -ex; \
    apk add --no-cache --virtual .buildDeps gcc libcouchbase-dev; \
    apk add --no-cache libcouchbase; \
    pip install --no-cache 'couchbase<2.4.0'; \
    apk del .buildDeps

You have to use version < 2.4.0 due to this issue. For newer versions and other platforms, as @tao12345666333 said, you should consult the Couchbase docs or ask in a Couchbase forum.

Since this is not a problem with the image, but in using the image, in the future, it'd be better to post questions like this in the Docker Community Forums, the Docker Community Slack, or Stack Overflow.

Some alternatives (if useful)...

Edge repos:

apk add --no-cache --virtual .build-deps \
    linux-headers \
    libcrypto1.1 \
    libssl1.1 \
    --repository http://uk.alpinelinux.org/alpine/edge/main/ build-base

apk add --no-cache --virtual .couchbase \
    libcouchbase==2.9.5-r1 \
    libcouchbase-dev=2.9.5-r1 \
    --repository http://uk.alpinelinux.org/alpine/edge/community/ build-base

apk del .build-deps

pip install couchbase

Building from source:

WORKDIR /tmp
RUN apk add --no-cache gcc musl-dev
RUN apk update && \
    apk add git g++ make cmake libevent-dev libev-dev perl
RUN git clone git://github.com/couchbase/libcouchbase.git && \
    mkdir libcouchbase/build

WORKDIR /tmp/libcouchbase/build
ARG TAG=2.9.3
RUN git checkout tags/$TAG
RUN ../cmake/configure --prefix=/usr && \
      make && \
      make install

pip install couchbase

Thanks all for your help

Was this page helpful?
0 / 5 - 0 ratings