FROM node:18 # Set environment variables ENV PLAYWRIGHT_BROWSERS_PATH=/ms-playwright ENV NODE_ENV=production ENV DEBIAN_FRONTEND=noninteractive # Disable browser download during npm install for the mcp package itself ENV PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 # Install system dependencies for Playwright # We'll create packages.txt next COPY ./packages.txt /tmp/packages.txt RUN apt-get update && \ apt-get install -y --no-install-recommends $(cat /tmp/packages.txt) && \ # Clean up apt caches apt-get install -y python3 && \ rm -rf /var/lib/apt/lists/* # Create app directory WORKDIR /app # Install app dependencies (Playwright MCP) COPY package.json ./ # COPY package-lock.json ./ # RUN npm ci --only=production RUN npm install # Manually install Playwright browsers with proper permissions # This ensures browsers are available at PLAYWRIGHT_BROWSERS_PATH RUN mkdir -p ${PLAYWRIGHT_BROWSERS_PATH} && \ chmod -R 777 ${PLAYWRIGHT_BROWSERS_PATH} && \ # Install only chromium as an example, adjust if other browsers are needed by mcp-config.json npx playwright install chromium --with-deps && \ # Verify installation ls -la ${PLAYWRIGHT_BROWSERS_PATH} && \ # Ensure permissions are set correctly after installation for the runtime user chmod -R 777 ${PLAYWRIGHT_BROWSERS_PATH} # Bundle MCP configuration AND our test server # COPY mcp-config.json ./ # COPY app.js ./ # Bundle app source COPY . . RUN chmod 644 /app/mcp-config.json # Set correct permissions for file access RUN chmod -R 755 /app && \ # Make sure the app user has permissions to create files if needed chmod 777 /app # Expose the port MCP server will listen on (defined in mcp-config.json) # This is for Docker internal, README.md handles HF exposure EXPOSE 7860 # Start the Playwright MCP server CMD ["node", "node_modules/@playwright/mcp/cli.js", "--config", "mcp-config.json"]