Skip to content

Commit f2744a4

Browse files
committed
Working
1 parent 21998d3 commit f2744a4

File tree

1 file changed

+21
-28
lines changed

1 file changed

+21
-28
lines changed

python-crawl4ai/src/extensions/playwrightExtension.ts

Lines changed: 21 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,6 @@ class PlaywrightExtension implements BuildExtension {
2626
}
2727

2828
onBuildComplete(context: BuildContext) {
29-
if (context.target === "dev") return;
30-
31-
context.logger.debug(
32-
`Adding ${this.name} to the build with browsers: ${
33-
this.options.browsers.join(", ")
34-
}`,
35-
);
36-
3729
const instructions: string[] = [
3830
// Base dependencies
3931
`RUN apt-get update && apt-get install -y --no-install-recommends \
@@ -131,28 +123,29 @@ class PlaywrightExtension implements BuildExtension {
131123
// Setup Playwright browsers
132124
instructions.push(`RUN mkdir -p /ms-playwright`);
133125
instructions.push(
134-
`RUN npx playwright install --dry-run > /tmp/browser-info.txt`,
126+
// `RUN npx playwright install --dry-run > /tmp/browser-info.txt`,
127+
`RUN PLAYWRIGHT_BROWSERS_PATH=/ms-playwright python -m playwright install --with-deps chromium`,
135128
);
136129

137-
this.options.browsers.forEach((browser) => {
138-
const browserType = browser === "chromium"
139-
? "chromium-headless-shell"
140-
: browser;
141-
142-
instructions.push(
143-
`RUN grep -A5 "browser: ${browserType}" /tmp/browser-info.txt > /tmp/${browser}-info.txt`,
144-
`RUN INSTALL_DIR=$(grep "Install location:" /tmp/${browser}-info.txt | cut -d':' -f2- | xargs) && \
145-
DIR_NAME=$(basename "$INSTALL_DIR") && \
146-
MS_DIR="/ms-playwright/$DIR_NAME" && \
147-
mkdir -p "$MS_DIR"`,
148-
`RUN DOWNLOAD_URL=$(grep "Download url:" /tmp/${browser}-info.txt | cut -d':' -f2- | xargs | sed "s/mac-arm64/linux/g" | sed "s/mac-15-arm64/ubuntu-20.04/g") && \
149-
echo "Downloading ${browser} from $DOWNLOAD_URL" && \
150-
curl -L -o /tmp/${browser}.zip "$DOWNLOAD_URL" && \
151-
unzip -q /tmp/${browser}.zip -d "/ms-playwright/$(basename $(grep "Install location:" /tmp/${browser}-info.txt | cut -d':' -f2- | xargs))" && \
152-
chmod -R +x "/ms-playwright/$(basename $(grep "Install location:" /tmp/${browser}-info.txt | cut -d':' -f2- | xargs))" && \
153-
rm /tmp/${browser}.zip`,
154-
);
155-
});
130+
// this.options.browsers.forEach((browser) => {
131+
// const browserType = browser === "chromium"
132+
// ? "chromium-headless-shell"
133+
// : browser;
134+
135+
// instructions.push(
136+
// `RUN grep -A5 "browser: ${browserType}" /tmp/browser-info.txt > /tmp/${browser}-info.txt`,
137+
// `RUN INSTALL_DIR=$(grep "Install location:" /tmp/${browser}-info.txt | cut -d':' -f2- | xargs) && \
138+
// DIR_NAME=$(basename "$INSTALL_DIR") && \
139+
// MS_DIR="/ms-playwright/$DIR_NAME" && \
140+
// mkdir -p "$MS_DIR"`,
141+
// `RUN DOWNLOAD_URL=$(grep "Download url:" /tmp/${browser}-info.txt | cut -d':' -f2- | xargs | sed "s/mac-arm64/linux/g" | sed "s/mac-15-arm64/ubuntu-20.04/g") && \
142+
// echo "Downloading ${browser} from $DOWNLOAD_URL" && \
143+
// curl -L -o /tmp/${browser}.zip "$DOWNLOAD_URL" && \
144+
// unzip -q /tmp/${browser}.zip -d "/ms-playwright/$(basename $(grep "Install location:" /tmp/${browser}-info.txt | cut -d':' -f2- | xargs))" && \
145+
// chmod -R +x "/ms-playwright/$(basename $(grep "Install location:" /tmp/${browser}-info.txt | cut -d':' -f2- | xargs))" && \
146+
// rm /tmp/${browser}.zip`,
147+
// );
148+
// });
156149

157150
// Environment variables
158151
const envVars: Record<string, string> = {

0 commit comments

Comments
 (0)