Dockerfile
1 # Copyright 2025 Alibaba Group Holding Ltd. 2 # 3 # Licensed under the Apache License, Version 2.0 (the "License"); 4 # you may not use this file except in compliance with the License. 5 # You may obtain a copy of the License at 6 # 7 # http://www.apache.org/licenses/LICENSE-2.0 8 # 9 # Unless required by applicable law or agreed to in writing, software 10 # distributed under the License is distributed on an "AS IS" BASIS, 11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 # See the License for the specific language governing permissions and 13 # limitations under the License. 14 15 FROM debian:12-slim 16 17 #---------------------- 18 # Install all prerequisite packages in one layer 19 RUN apt-get update && apt-get install -y \ 20 python3 \ 21 python3-pip \ 22 python3-venv \ 23 wget \ 24 ca-certificates \ 25 curl \ 26 git \ 27 nodejs \ 28 npm \ 29 --no-install-recommends \ 30 && rm -rf /var/lib/apt/lists/* 31 32 #---------------------- 33 # Create a non-root user and browser cache dir early (needed before chown) 34 RUN groupadd -r playwright && useradd -r -g playwright playwright \ 35 && mkdir -p /home/playwright /ms-playwright \ 36 && chown -R playwright:playwright /home/playwright /ms-playwright 37 38 #---------------------- 39 # Install Playwright and browser binaries 40 # Use an isolated venv to avoid PEP 668 issues 41 ENV PLAYWRIGHT_BROWSERS_PATH=/ms-playwright 42 43 RUN python3 -m venv /venv \ 44 && /venv/bin/pip install --no-cache-dir --upgrade pip \ 45 && /venv/bin/pip install --no-cache-dir playwright \ 46 && npm install -g @playwright/mcp \ 47 && /venv/bin/playwright install --with-deps chromium 48 49 ENV PATH="/venv/bin:${PATH}" 50 51 #---------------------- 52 # Configure user, etc 53 54 WORKDIR /home/playwright 55 56 USER playwright 57 58 # Default to bash 59 CMD ["bash"]