slidevjs / container

Container building scripts for Slidev
MIT License
35 stars 7 forks source link

slidev export failed in container #3

Open kkongling opened 3 years ago

kkongling commented 3 years ago

command:

~/slides # cd /root/
~ # npm i playwright-chromium (work directory should be `/root/`)
~ # cd /root/slides
~/slides # ../node_modules/.bin/slidev export

Got err log:

  Slidev  v0.9.6

  theme   @slidev/theme-default
  entry   /root/slides/slides.md

(node:288) [DEP0148] DeprecationWarning: Use of deprecated folder mapping "./" in the "exports" field module resolution of the package at /root/node_modules/playwright-chromium/package.json.
Update this package.json to use a subpath pattern like "./*".
(Use `node --trace-deprecation ...` to show where the warning was created)
browserType.launch: Failed to launch: Error: spawn /root/.cache/ms-playwright/chromium-878941/chrome-linux/chrome ENOENT
=========================== logs ===========================
<launching> /root/.cache/ms-playwright/chromium-878941/chrome-linux/chrome --disable-background-networking --enable-features=NetworkService,NetworkServiceInProcess --disable-background-timer-throttling --disable-backgrounding-occluded-windows --disable-breakpad --disable-client-side-phishing-detection --disable-component-extensions-with-background-pages --disable-default-apps --disable-dev-shm-usage --disable-extensions --disable-features=TranslateUI,BlinkGenPropertyTrees,ImprovedCookieControls,SameSiteByDefaultCookies,LazyFrameLoading --allow-pre-commit-input --disable-hang-monitor --disable-ipc-flooding-protection --disable-popup-blocking --disable-prompt-on-repost --disable-renderer-backgrounding --disable-sync --force-color-profile=srgb --metrics-recording-only --no-first-run --enable-automation --password-store=basic --use-mock-keychain --no-service-autorun --user-data-dir=/tmp/playwright_chromiumdev_profile-aEEMoK --remote-debugging-pipe --headless --hide-scrollbars --mute-audio --blink-settings=primaryHoverType=2,availableHoverTypes=2,primaryPointerType=4,availablePointerTypes=4 --no-sandbox --no-startup-window
============================================================
Note: use DEBUG=pw:api environment variable to capture Playwright logs.
Error
    at Object.captureStackTrace (/root/node_modules/playwright-chromium/lib/utils/stackTrace.js:50:19)
    at Connection.sendMessageToServer (/root/node_modules/playwright-chromium/lib/client/connection.js:65:48)
    at Proxy.<anonymous> (/root/node_modules/playwright-chromium/lib/client/channelOwner.js:64:61)
    at /root/node_modules/playwright-chromium/lib/client/browserType.js:60:67
    at BrowserType._wrapApiCall (/root/node_modules/playwright-chromium/lib/client/channelOwner.js:77:34)
    at BrowserType.launch (/root/node_modules/playwright-chromium/lib/client/browserType.js:51:21)
    at exportSlides (/root/node_modules/@slidev/cli/dist/export-WGBEP3OU.js:62:34)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async Object.handler (/root/node_modules/@slidev/cli/dist/cli.js:212:12)
signed-log commented 3 years ago

Hello,

This error complains about Chromium not being able to launch, this is a known bug on Node alpine images see here, this will not be fixed on the alpine linux-based image, but I'll introduce a new tag with debian-based images to fix this bug

kkongling commented 3 years ago

I am building from ubuntu:

docker pull ubuntu:18.04
docker run -it -v /path/to/slidev:/root/slidev -p 3030:3030 ubuntu:18.04 /bin/bash

In container:

apt update
apt install -y curl
curl -fsSL https://deb.nodesource.com/setup_15.x | bash -
apt install -y nodejs
apt install -y chromium-browser

npm install @slidev/cli @slidev/theme-default
npm install playwright-chromium playwright
npx slidev export

Got err log:

  Slidev  v0.9.8

  theme   @slidev/theme-default
  entry   /root/slidev/demo/slides.md

browserType.launch: Failed to launch chromium because executable doesn't exist at /root/.cache/ms-playwright/chromium-878941/chrome-linux/chrome
Try re-installing playwright with "npm install playwright"
Error
    at Object.captureStackTrace (/root/slidev/demo/node_modules/playwright-chromium/lib/utils/stackTrace.js:50:19)
    at Connection.sendMessageToServer (/root/slidev/demo/node_modules/playwright-chromium/lib/client/connection.js:65:48)
    at Proxy.<anonymous> (/root/slidev/demo/node_modules/playwright-chromium/lib/client/channelOwner.js:64:61)
    at /root/slidev/demo/node_modules/playwright-chromium/lib/client/browserType.js:60:67
    at BrowserType._wrapApiCall (/root/slidev/demo/node_modules/playwright-chromium/lib/client/channelOwner.js:77:34)
    at BrowserType.launch (/root/slidev/demo/node_modules/playwright-chromium/lib/client/browserType.js:51:21)
    at exportSlides (/root/slidev/demo/node_modules/@slidev/cli/dist/export-WGBEP3OU.js:62:34)
    at processTicksAndRejections (node:internal/process/task_queues:94:5)
    at async Object.handler (/root/slidev/demo/node_modules/@slidev/cli/dist/cli.js:212:12)

I want to run slidev in container, and export pdf file. Any suggestion?

signed-log commented 3 years ago

@kkongling Sorry for the wait, issue is on the way of being fixed

fabianhauser commented 3 years ago

@Stig124 there seem to be a few commits on the dev branch, are you still working on this or is the issue waiting on contributions?

WinterYukky commented 2 years ago

This Dockerfile can resolve this issue.

FROM mcr.microsoft.com/playwright:focal
RUN yarn global add @slidev/cli

how to use

  1. Build this Dockerfile and open.
  2. Execute next commands.
    1. yarn create slidev
    2. cd <project-directory>
    3. yarn add playwright-chromium
    4. yarn slidev export