Docker and playwright

Viewed 1432

I need to install 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 the below error. I tried installing everything in the error message but it didn't 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

enter image description here

3 Answers

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 - Docker docs for the latest playwright version.

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.

Related