微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

将 watchman 安装到 Python docker 容器中时出错

如何解决将 watchman 安装到 Python docker 容器中时出错

如何将 watchman 安装到我的 python docker 容器中?我已经尝试按照守望者 documentation 中的描述从源代码安装它,但没有成功。这是我的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

这是我尝试构建映像时的错误

$ 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,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

有什么办法可以解决这个问题吗?或者有没有更好的方法将watchman安装到这个容器中?

解决方法

或者有没有更好的方法将 watchman 安装到这个容器中?

是的,您可以直接将其预编译的二进制文件安装到容器中,无需从源代码构建,请参阅 this

接下来是一个完整的解决方案,仅供参考。

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

验证:

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

您可以看到我们现在已经可以运行 watchman command

顺便说一句,所有预定义的二进制文件都可以在 github 中找到。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?