pythondockerwatchman

Error installing watchman into a Python docker container


How can I install watchman into my python docker container? I've tried installing it from source as described in the watchman documentation but no luck. Here's is my Dockerfile:

FROM python:3.9

# install watchman
RUN git clone https://github.com/facebook/watchman.git -b v4.9.0 --depth 1 && \
  cd watchman && \
  ./autogen.sh && \
  ./configure && \
  make && \
  make install

Here is the error when I try to build the image:

$ docker image build --tag pythonwatchman .
...
#5 141.5   CXX      root/watchman-warnerr.o
#5 143.0   CXX      root/watchman-watchlist.o
#5 144.9   CXX      scm/watchman-Mercurial.o
#5 145.6 scm/Mercurial.cpp: In constructor ‘watchman::Mercurial::infoCache::infoCache(std::__cxx11::string)’:
#5 145.6 scm/Mercurial.cpp:16:40: error: ‘void* memset(void*, int, size_t)’ clearing an object of non-trivial type ‘struct watchman::FileInformation’; use assignment or value-initialization instead [-Werror=class-memaccess]
#5 145.6    memset(&dirstate, 0, sizeof(dirstate));
#5 145.6                                         ^
#5 145.6 In file included from scm/Mercurial.h:10,
#5 145.6                  from scm/Mercurial.cpp:3:
#5 145.6 ./FileInformation.h:18:8: note: ‘struct watchman::FileInformation’ declared here
#5 145.6  struct FileInformation {
#5 145.6         ^~~~~~~~~~~~~~~
#5 146.8 cc1plus: all warnings being treated as errors
#5 146.8 make[1]: *** [Makefile:4446: scm/watchman-Mercurial.o] Error 1
#5 146.8 make[1]: Leaving directory '/watchman'
#5 146.8 make: *** [Makefile:1264: all] Error 2

Is there any way to fix this? Or is there a better way to install watchman into this container?


Solution

  • Or is there a better way to install watchman into this container?

    YES, you can directly install their pre-compiled binary to container, no need to build from source, see this.

    Next is a whole solution, FYI.

    Dockerfile:

    FROM python:3.9
    
    ARG WM_VERSION=v2021.03.01.00
    
    # install watchman
    RUN wget https://github.com/facebook/watchman/releases/download/$WM_VERSION/watchman-$WM_VERSION-linux.zip && \
    unzip watchman-$WM_VERSION-linux.zip && \
    cd watchman-$WM_VERSION-linux && \
    mkdir -p /usr/local/{bin,lib} /usr/local/var/run/watchman && \
    cp bin/* /usr/local/bin && \
    cp lib/* /usr/local/lib && \
    chmod 755 /usr/local/bin/watchman && \
    chmod 2777 /usr/local/var/run/watchman && \
    cd .. && \
    rm -fr watchman-$WM_VERSION-linux.zip watchman-$WM_VERSION-linux
    

    Verify:

    $ docker build -t abc:1 .
    $ docker run --rm -it abc:1 watchman --version
    20210222.215625.0
    

    You could see we already could run watchman command now.

    BTW, all the predefined binary could be found in github.