我有一个小应用程序,使用playwright从各种网站上抓取数据。应用程序的Dockerized很好,一切工作都很完美,直到我试图重新构建Docker镜像(代码中没有真正改变),它无法安装剧作家deps(就像以前一样)。
这就是Dockerfile:
FROM python:3.9-slim
COPY ../../requirements/dev.txt ./
RUN python3 -m ensurepip
RUN pip install -r dev.txt
RUN playwright install
RUN playwright install-deps
ENV PYTHONPATH "${PYTHONPATH}:/app/"
WORKDIR /code/src
EXPOSE 8000
COPY ./src /app
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000", "--reload"]
这是要求:
fastapi>=0.85.0
uvicorn>=0.18.3
bs4==0.0.1
playwright
这是错误消息:
=> ERROR [6/8] RUN playwright install-deps 4.1s
------
> [6/8] RUN playwright install-deps:
#10 0.762 BEWARE: your OS is not officially supported by Playwright; installing dependencies for Ubuntu as a fallback.
#10 0.762 Installing dependencies...
#10 1.084 Get:1 http://deb.debian.org/debian bookworm InRelease [147 kB]
#10 1.269 Get:2 http://deb.debian.org/debian bookworm-updates InRelease [52.1 kB]
#10 1.338 Get:3 http://deb.debian.org/debian-security bookworm-security InRelease [48.0 kB]
#10 1.407 Get:4 http://deb.debian.org/debian bookworm/main amd64 Packages [8904 kB]
#10 2.278 Get:5 http://deb.debian.org/debian-security bookworm-security/main amd64 Packages [24.2 kB]
#10 3.063 Fetched 9176 kB in 2s (4021 kB/s)
#10 3.063 Reading package lists...
#10 3.474 Reading package lists...
#10 3.868 Building dependency tree...
#10 3.969 Reading state information...
#10 3.972 Package ttf-ubuntu-font-family is not available, but is referred to by another package.
#10 3.972 This may mean that the package is missing, has been obsoleted, or
#10 3.972 is only available from another source
#10 3.972
#10 3.972 Package libjpeg-turbo8 is not available, but is referred to by another package.
#10 3.972 This may mean that the package is missing, has been obsoleted, or
#10 3.972 is only available from another source
#10 3.972
#10 3.972 Package ttf-unifont is not available, but is referred to by another package.
#10 3.972 This may mean that the package is missing, has been obsoleted, or
#10 3.972 is only available from another source
#10 3.972 However the following packages replace it:
#10 3.972 fonts-unifont
#10 3.972
#10 3.972 Package xfonts-cyrillic is not available, but is referred to by another package.
#10 3.972 This may mean that the package is missing, has been obsoleted, or
#10 3.972 is only available from another source
#10 3.972
#10 3.974 E: Package 'ttf-unifont' has no installation candidate
#10 3.974 E: Package 'xfonts-cyrillic' has no installation candidate
#10 3.974 E: Package 'ttf-ubuntu-font-family' has no installation candidate
#10 3.974 E: Unable to locate package libx264-155
#10 3.974 E: Unable to locate package libenchant1c2a
#10 3.974 E: Unable to locate package libicu66
#10 3.974 E: Package 'libjpeg-turbo8' has no installation candidate
#10 3.974 E: Unable to locate package libvpx6
#10 3.974 E: Unable to locate package libwebp6
#10 3.975 Failed to install browser dependencies
#10 3.975 Error: Installation process exited with code: 100
------
executor failed running [/bin/sh -c playwright install-deps]: exit code: 1
我运行的命令是'docker-compose build'。希望有人能帮忙,谢谢。
2条答案
按热度按时间v8wbuo2f1#
解决方案:我将基础映像更改为较新版本,现在它可以正常工作。
inkz8wg92#
这是因为在2023年6月10日,debian发布了一个新版本"bookworm",它似乎破坏了playwright的集成,所以为了修复,你可以将基本映像更改为
bullseye
标签,slim
始终使用最新的debian稳定版本。