heroku-buildpack-couchbase-python

by utribo

GitHub Readme.md

Couchbase Client buildpack: Python

This is a Couchbase Client Heroku buildpack for Python apps, powered by pip.

Usage

Example usage:

$ ls
Procfile  requirements.txt  web.py

$ heroku create --buildpack git://github.com/utribo/heroku-buildpack-couchbase-python.git

$ git push heroku master
...
-----> Python app detected
-----> Installing runtime (python-2.7.9)
-----> Noticed couchbase. Bootstrapping libcouchbase.
-----> Installing dependencies using pip
       Downloading/unpacking couchbase (from -r requirements.txt (line 1))
       Installing collected packages: couchbase
       Successfully installed couchbase
       Cleaning up...
-----> Discovering process types
       Procfile declares types -> (none)

You can also add it to upcoming builds of an existing application:

$ heroku buildpacks:set git://github.com/utribo/heroku-buildpack-couchbase-python.git

Note that in this case you must also add the config vars to your heroku app:

$ heroku config:set LD_LIBRARY_PATH=/app/.heroku/vendor/libcouchbase/lib

The buildpack will detect your app as Python if it has the file requirements.txt in the root.

It will use Pip to install your dependencies, vendoring a copy of the Python runtime into your slug.

Specify a Runtime

You can also provide arbitrary releases Python with a runtime.txt file.

$ cat runtime.txt
python-3.4.3

Runtime options include:

  • python-2.7.9
  • python-3.4.3
  • pypy-2.4.0 (unsupported, experimental)
  • pypy3-2.4.0 (unsupported, experimental)

Build Couchbase C library dependencies

Couchbase python client requires the C binary libcouchbase >= 2.4.7 to be available. Embeded with the buildpack is the version 2.5.2 of the C library. In order to update libcouchbase, it is require to pre-compile the libcouchbase C library as a library vendor.

Pre-compilation was done with ubuntu 14.04 TLS as it's the same build as heroku cedar-14. Because we cannot do this pre-compilation directly within a heroku app, we build it on a similar OS. To ease this build we use a docker container. You can find in this project a Dockerfile to build the container and get an archived version of libcouchbase.

Build docker container

$ docker build -t libcouchbase .

Run the libcouchbase server

$ docker run -it libcouchbase
...
srvdir by @inconshreveable

Serving
https://[your-unique-url].srvdir.net -> /app

Then on your local computer open Google Chrome.

Visit the url https://[your-unique-url].srvdir.net/libcouchbase.tar.gz to download the tar.gz to your machine.

Untar the file and replace the vendor corresponding library in this builbpack project.

$ tar xvzf libcouchbase.tar.gz

To change libcouchbase version, edit Dockerfile