我试图在docker容器中运行lektor,但遇到了一个问题。在
如果我在Dockerfile中“添加”(或“复制”)源代码文件夹,一切都会完美地工作,但是,当然,容器不是动态的,不会响应代码中的更改。在
相反,如果我使用了一个卷,容器就会变成动态的,lektor会在我进行更改时成功地重建和服务于我的站点。在
但是,当我发布站点时,容器的日志中会出现一个错误,它将进入一个永无止境的循环:
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。在
最小停靠器-合成.yml:
version: '2'
services:
web:
build: .
ports:
- "5000:5000"
volumes:
- .:/project
working_dir: /project/source
command: ['lektor', 'server', '--host', '0.0.0.0.']
(我的项目文件夹的结构使得lektor项目文件和所有预期的lektor文件夹都位于“source”子文件夹中)。在
lektor构建过程使用硬链接和构建文件的临时文件夹。如果源代码在一个挂载的卷上(它在docker卷中),那么两个文件系统不同,并且链接失败,如上所述。在
通过命令行部署和构建并指定输出路径可以解决这个问题(在这里描述:https://www.getlektor.com/docs/deployment/),但在Docker容器中,这不是一个很好的解决方案,因为Docker容器的目标是使生活尽可能简单。在
在lektor中执行链接的方法实际上在某些情况下会返回到复制。我创建了一个问题(https://github.com/lektor/lektor/issues/315),表明如果项目和输出文件夹位于不同的卷上,也会发生回退。我想这能很好地解决问题。在
相关问题 更多 >
编程相关推荐