Here is what I have in my Dockerfile. The following is tested and launched in production on top of the Debian Stretch. I recommend using the PyV8 / V8 settings that I use - I spent at least a week to figure out which combination does not lead to memory leaks. I also recommend reading the discussion, and the official approval of JSContext here and here .
In short, support for PyV8 almost does not exist - either you use it, either as a toy, or follow this recipe, or spend a significant amount of time and effort to develop a repo and make it better. If you are starting fresh, I recommend using Node -JS instead and communicating through some IPC method with Python.
ENV MY_HOME /home/forge ENV MY_LIB $FORGE_HOME/lib # preparing dependencies for V8 and PyV8 ENV V8_HOME $MY_LIB/v8 RUN apt-get update && \ apt-get install -y libboost-thread-dev \ libboost-all-dev \ libboost-dev \ libboost-python-dev \ autoconf \ libtool \ systemtap \ scons # compiling an older version of boost, required for this version of V8 RUN mkdir -p $MY_LIB/boost && cd $MY_LIB/boost && \ wget http://sourceforge.net/projects/boost/files/boost/1.54.0/boost_1_54_0.tar.gz && tar -xvzf boost_1_54_0.tar.gz && cd $MY_LIB/boost/boost_1_54_0 && \ ./bootstrap.sh && \ ./b2 install --prefix=/usr/local --with-python --with-thread && \ ldconfig && \ ldconfig /usr/local/lib # preparing gcc 4.9 - anything newer will lead to errors with the V8 codebase ENV CC "gcc-4.9" ENV CPP "gcc-4.9 -E" ENV CXX "g++-4.9" ENV PATH_BEFORE_V8 "${MY_HOME}/bin:${PATH}" ENV PATH "${MY_HOME}/bin:${PATH}" RUN echo "deb http://ftp.us.debian.org/debian/ jessie main contrib non-free" >> /etc/apt/sources.list && \ echo "deb-src http://ftp.us.debian.org/debian/ jessie main contrib non-free" >> /etc/apt/sources.list && \ apt-get update && \ apt-get install -y gcc-4.9 g++-4.9 && \ mkdir -p ${MY_HOME}/bin && cd ${MY_HOME}/bin && \ ln -s /usr/bin/${CC} ${MY_HOME}/bin/gcc && \ ln -s /usr/bin/${CC} ${MY_HOME}/bin/x86_64-linux-gnu-gcc && \ ln -s /usr/bin/${CXX} ${MY_HOME}/bin/g++ && \ ln -s /usr/bin/${CXX} ${MY_HOME}/bin/x86_64-linux-gnu-g++ # compiling a specific version of V8 and PyV8, since older combos lead to memory leaks RUN git clone https://github.com/muellermichel/V8_r10452.git $V8_HOME && \ git clone https://github.com/muellermichel/PyV8_r429.git $MY_LIB/pyv8 && \ cd $MY_LIB/pyv8 && python setup.py build && python setup.py install # cleaning up RUN PATH=${PATH_BEFORE_V8} && \ head -n -2 /etc/apt/sources.list > ${MY_HOME}/sources.list.temp && \ mv ${MY_HOME}/sources.list.temp /etc/apt/sources.list && \ apt-get update ENV PATH "${PATH_BEFORE_V8}" ENV CC "" ENV CPP "" ENV CXX ""
an older version, which depends on the now missing google code and was made for Ubuntu 12.04:
export MY_LIB_FOLDER=[PUT-YOUR-DESIRED-INSTALL-PATH-HERE] apt-get install -y libboost-thread-dev apt-get install -y libboost-all-dev apt-get install -y libboost-dev apt-get install -y libboost-python-dev apt-get install -y git-core autoconf libtool systemtap apt-get install -y subversion apt-get install -y wget mkdir -p $MY_LIB_FOLDER/boost && cd $MY_LIB_FOLDER/boost && wget http://sourceforge.net/projects/boost/files/boost/1.54.0/boost_1_54_0.tar.gz && tar -xvzf boost_1_54_0.tar.gz cd $MY_LIB_FOLDER/boost/boost_1_54_0 && ./bootstrap.sh && ./b2 install
Michel MΓΌller Feb 10 '15 at 1:39 2015-02-10 01:39
source share