FROM mcr.microsoft.com/playwright:v1.47.0-noble RUN apt-get update -q && apt-get install -qy python3 python3-pip # Switch to the "ubuntu" user USER ubuntu # Set home to the ubuntu's home directory ENV HOME=/home/ubuntu \ PATH=/home/ubuntu/.local/bin:$PATH # Set the working directory to the user's home directory WORKDIR $HOME/app # Try and run pip command after setting the user with `USER user` to avoid permission issues with Python COPY --chown=ubuntu requirements.txt $HOME/app RUN pip install --no-cache-dir --upgrade -r requirements.txt --break-system-packages # Copy the current directory contents into the container at $HOME/app setting the owner to the user COPY --chown=ubuntu app.py $HOME/app EXPOSE 7860 ENTRYPOINT [ "python3" ] CMD [ "app.py" ]