我如何在Docker容器中运行Lektor?

我试图在docker集装箱内运行lektor,并遇到了问题。

如果我在我的Dockerfile中添加(或复制)我的源代码文件夹,一切正常,但是,当然,容器不是dynamic的,不会响应代码中的变化。

相反,如果我使用卷,那么容器就会变成dynamic的,并且在我进行更改时成功地重build并为我的站点提供服务。

但是,当我来发布站点时,容器的日志中会出现一个错误,并进入一个永无止境的循环:

Started build Debugging middleware caught exception in streamed response at a point where response headers were already sent. Traceback (most recent call last): File "/usr/local/lib/lektor/lib/python2.7/site-packages/lektor/admin/utils.py", line 18, in generate for event in chain(f(*args, **kwargs), (None,)): File "/usr/local/lib/lektor/lib/python2.7/site-packages/lektor/admin/modules/api.py", line 309, in generator for event in event_iter: File "/usr/local/lib/lektor/lib/python2.7/site-packages/lektor/publisher.py", line 639, in publish self.link_artifacts(path) File "/usr/local/lib/lektor/lib/python2.7/site-packages/lektor/publisher.py", line 602, in link_artifacts link(full_path, dst) OSError: [Errno 18] Invalid cross-device link

最小的Dockerfile:

 FROM python:2.7.11 RUN curl -sf https://www.getlektor.com/install.sh | \ sed '/stdin/d;s/input = .*/return/' | \ sh 

我实际上是在使用docker-compose。

最小的docker-compose.yml: version: '2' services: web: build: . ports: - "5000:5000" volumes: - .:/project working_dir: /project/source command: ['lektor', 'server', '--host', '0.0.0.0.'] :。 version: '2' services: web: build: . ports: - "5000:5000" volumes: - .:/project working_dir: /project/source command: ['lektor', 'server', '--host', '0.0.0.0.']

(我的项目文件夹的结构使得lektor项目文件和所有预期的lektor文件夹都位于“源”子文件夹中)。

lektor构build过程为构build的文件使用硬链接和临时文件夹。 如果源代码位于装入的卷上(它位于docker卷中),那么这两个文件系统是不同的,并且链接失败,如上所述。

通过命令行进行部署和构build并指定输出path可以解决此问题(在此处进行了描述: https : //www.getlektor.com/docs/deployment/ ),但在Docker容器中,这不是一个好的解决scheme就是让生活尽可能简单。

在某些情况下,执行lektor内部链接的方法实际上会退回到复制。 我创build了一个问题( https://github.com/lektor/lektor/issues/315 ),build议还会出现回退的是项目和输出文件夹在不同的卷上。 我怀疑这会正确地解决问题。