Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with running in docker #90

Open
crbon opened this issue Dec 14, 2023 · 3 comments
Open

Issue with running in docker #90

crbon opened this issue Dec 14, 2023 · 3 comments

Comments

@crbon
Copy link

crbon commented Dec 14, 2023

Not sure what I'm doing wrong, but can't seem to get deno-puppeteer working in docker. It works fine if I run the deno --allow-all main.js.

Error

Interrupted: operation canceled
    at async read (ext:deno_io/12_io.js:102:17)
    at async readDelim (https://deno.land/std@0.93.0/io/bufio.ts:652:20)
    at async readStringDelim (https://deno.land/std@0.93.0/io/bufio.ts:702:20)
    at async readLines (https://deno.land/std@0.93.0/io/bufio.ts:711:18)
    at async waitForWSEndpoint (https://deno.land/x/puppeteer@16.2.0/src/deno/BrowserRunner.ts:168:20)
    at async BrowserRunner.setupConnection (https://deno.land/x/puppeteer@16.2.0/src/deno/BrowserRunner.ts:146:31)
    at async ChromeLauncher.launch (https://deno.land/x/puppeteer@16.2.0/src/deno/Launcher.ts:114:26)
    at async loginToRouter (file:///app/main.js:55:19)
    at async maintainInternetConnectivity (file:///app/main.js:144:9) {
  name: "Interrupted",
  code: "EINTR"
}

If I leave it running longer it'll give a timeout error.

Code snippet

import puppeteer from "https://deno.land/x/[email protected]/mod.ts";
...
async function loginToRouter() {
  const browser = await puppeteer.launch({
    headless: true,
    args: ["--no-sandbox", "--disable-setuid-sandbox", "--disable-dev-shm-usage"],
  });
}
...

Dockerfile

FROM denoland/deno:1.39.0

WORKDIR /app

USER root # have tried with an without root

COPY . .

RUN deno cache main.js

RUN PUPPETEER_PRODUCT=chrome deno run -A --unstable https://deno.land/x/[email protected]/install.ts

CMD ["deno", "run", "--allow-all", "--unstable", "main.js"] # for testing only, but still doesn't work
@BrunoBernardino
Copy link

@crbon did you solve this? I'm running into the same issue.

@crbon
Copy link
Author

crbon commented Jan 17, 2024

@BrunoBernardino unfortunately I haven't worked it out, the issues is still present.

@BrunoBernardino
Copy link

BrunoBernardino commented Jan 17, 2024

Thanks. I also tried npm:puppeteer and ran into similar issues. I basically ended up switching to using wkhtmltopdf since I was using puppeteer to generate a PDF of an HTML document. I install the command in the docker machine and just call new Deno.Command('wkhtmltopdf', { args: ['file://<htmlFilePath>', '<pdfFilePath>'] }); from the code, now.

If anyone's curious, here's my Dockerfile:

# wkhtmltopdf image needed to more quickly build bins
FROM surnet/alpine-wkhtmltopdf:3.19.0-0.12.6-full as wkhtmltopdf
FROM denoland/deno:alpine-1.39.3

# wkhtmltopdf install dependencies
RUN apk add --no-cache \
        libstdc++ \
        libx11 \
        libxrender \
        libxext \
        libssl1.1 \
        xvfb \
        ca-certificates \
        fontconfig \
        freetype \
        ttf-droid \
        ttf-freefont \
        ttf-liberation \
        # more fonts
        ;

# wkhtmltopdf copy bins from ext image
COPY --from=wkhtmltopdf /bin/wkhtmltopdf /bin/libwkhtmltox.so /bin/

RUN ln -s /bin/wkhtmltopdf /usr/local/bin/wkhtmltopdf;
RUN chmod +x /usr/local/bin/wkhtmltopdf;

EXPOSE 8000

# Prefer not to run as root.
USER deno

WORKDIR /app

# These steps will be re-run upon each file change in your working directory:
ADD . /app

# Compile the main app so that it doesn't need to be compiled each startup/entry.
RUN deno cache --reload main.ts

CMD ["run", "--allow-all", "main.ts"]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants