'Docker and playwright
Hi i have a instrucions that i need to isntall playwright inside of docker.
This is my dockerfile
FROM python:3.9
EXPOSE 8000
WORKDIR /fastanalytics
COPY /requirements.txt /fastanalytics/requirements.txt
RUN pip install --no-cache-dir --upgrade -r /fastanalytics/requirements.txt
RUN playwright install
RUN playwright install-deps
RUN apt-get update && apt-get upgrade -y
But when i am installing i got this, i tried run install everything that wrote in this error, but didnt help
E: Package 'ttf-ubuntu-font-family' has no installation candidate
E: Unable to locate package libenchant1c2a
E: Unable to locate package libicu66
E: Package 'libjpeg-turbo8' has no installation candidate
Solution 1:[1]
Microsoft released a python docker image for Playwright
Dockerfile
# Build Environment: Playwright
FROM mcr.microsoft.com/playwright/python:v1.21.0-focal
# Add python script to Docker
COPY index.py /
# Run Python script
CMD [ "python", "index.py" ]
Check playwright docs for the latest playwright version.
Solution 2:[2]
Based on their docs (https://playwright.dev/python/docs/cli#install-system-dependencies), it looks like they only officially support Ubuntu systems whereas the python:3.9
is based off of Debian. Try using Ubuntu as your base image and install python on it:
FROM ubuntu:20.04
RUN apt update
RUN apt install python3.9
...
Solution 3:[3]
RUN apt-get update && playwright install-deps
While I have not used playwright, this seems to be a Docker issue. Playwright seems to be using apt-get
to install the dependencies. In that case, you need to ensure apt-get update
is run before playwright install-deps
. While you can use two separate RUN
statements to accomplish this, it is not advisable sinceapt-get update
may not be run because of Docker's caching capabilities.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | wanna_coder101 |
Solution 2 | MrDiggles |
Solution 3 | Ali Samji |