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

Ace HTTP CLI Dockerfile and .dockerignore #373

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

josteinaj
Copy link
Member

@josteinaj josteinaj commented Jun 24, 2022

Added Dockerfile. Fixes #372.

➜  ace git:(dockerfile) docker build .  
(…)
Successfully built 69fe3399436f
➜  ace git:(dockerfile) docker run --network host --rm -it --env ACE_PORT=80 69fe3399436f
yarn run v1.22.19
$ /usr/src/ace/node_modules/.bin/ace-http -v
1.2.7-alpha.3
Done in 0.37s.
yarn run v1.22.19
$ /usr/src/ace/node_modules/.bin/ace-http -H localhost -p 80 -l en
info:    [ace-http] server listening on http://localhost:80
~ curl http://localhost/jobs   
[]%
~ curl --form "epub=@/tmp/X60352A.epub" http://localhost/jobs/

{"job":"http://localhost:80/jobs/500dffb1-79bb-4c49-a504-b3bd9a6eaa04","status":1,"report":{}}%                                                                 
~ curl http://localhost:80/jobs/500dffb1-79bb-4c49-a504-b3bd9a6eaa04
{"job":"http://localhost:80/jobs/500dffb1-79bb-4c49-a504-b3bd9a6eaa04","status":1,"report":{}}%                                                                 
~ curl http://localhost:80/jobs/500dffb1-79bb-4c49-a504-b3bd9a6eaa04
{"job":"http://localhost:80/jobs/500dffb1-79bb-4c49-a504-b3bd9a6eaa04","status":0,"report":{"zip":"http://localhost:80/jobs/500dffb1-79bb-4c49-a504-b3bd9a6eaa04/report/?type=zip","json":"http://localhost:80/jobs/500dffb1-79bb-4c49-a504-b3bd9a6eaa04/report/?type=json"}}%

@danielweck
Copy link
Member

Hello, is apt-get install -y chromium really necessary, given that yarn install ensures Puppeteer is available to Ace's NodeJS scripts?

@josteinaj
Copy link
Member Author

josteinaj commented Mar 15, 2023

Hi!

Without apt-get install -y chromium, I get this when submitting a job to the API:

~/ace dockerfile !1 ❯ docker run --network host --rm -it --env ACE_PORT=80 dd4e0ac5be41
yarn run v1.22.19
$ /usr/src/ace/node_modules/.bin/ace-http -v
1.2.7-alpha.3
Done in 0.41s.
yarn run v1.22.19
$ /usr/src/ace/node_modules/.bin/ace-http -H localhost -p 80 -l en
info:    [ace-http] server listening on http://localhost:80
info:    [ace-http] Job started
info:    Processing /tmp/tmp-59-CW3qH3ly22aH/f8ad363d67976a50d301a7374410f050
info:    Parsing EPUB
info:    Analyzing accessibility metadata
info:    Checking package...
info:    - EPUB/package.opf: No issues found
error:   Ace processing error: Failed to launch the browser process!
/usr/src/ace/node_modules/puppeteer/.local-chromium/linux-991974/chrome-linux/chrome: error while loading shared libraries: libnss3.so: cannot open shared object file: No such file or directory


TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md

TypeError: Cannot read properties of undefined (reading 'internal')
    at /usr/src/ace/packages/ace-http/lib/index.js:195:57
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

With chromium installed using apt-get, it works:

~/ace dockerfile ❯ docker run --network host --rm -it --env ACE_PORT=80 a6c87e548719
yarn run v1.22.19
$ /usr/src/ace/node_modules/.bin/ace-http -v
1.2.7-alpha.3
Done in 0.42s.
yarn run v1.22.19
$ /usr/src/ace/node_modules/.bin/ace-http -H localhost -p 80 -l en
info:    [ace-http] server listening on http://localhost:80
info:    [ace-http] Job started
info:    Processing /tmp/tmp-59-e0vipyz29w3u/0d65d56cc5f1ba2d97eb93c95d45b9c1
info:    Parsing EPUB
info:    Analyzing accessibility metadata
info:    Checking package...
info:    - EPUB/package.opf: No issues found
info:    Checking documents...
info:    - X60352A-02-titlepage.xhtml: No issues found
info:    - X60352A-03-colophon.xhtml: No issues found
info:    - X60352A-01-cover.xhtml: No issues found
info:    - X60352A-04-foreword.xhtml: No issues found
info:    - X60352A-06-chapter.xhtml: No issues found
info:    - X60352A-07-chapter.xhtml: No issues found
info:    - X60352A-08-chapter.xhtml: No issues found
info:    - X60352A-05-chapter.xhtml: No issues found
info:    - X60352A-09-chapter.xhtml: No issues found
info:    - X60352A-10-chapter.xhtml: No issues found
info:    - X60352A-11-chapter.xhtml: No issues found
info:    - X60352A-12-chapter.xhtml: No issues found
info:    - X60352A-14-backmatter.xhtml: No issues found
info:    - nav.xhtml: No issues found
info:    - X60352A-13-chapter.xhtml: 8 issues found
info:    Consolidating results...
info:    Copying data
info:    Saving JSON report
info:    Saving HTML report
info:    Done.
info:    [ace-http] Job finished 9a2a513b-16b9-46c6-9b23-f30148c66866

@danielweck
Copy link
Member

Thank you for the explanation. I am familiar with globally or locally installing Chromium, Firefox etc. "drivers" in some cases with unit tests frameworks, but I incorrectly assumed that Puppeteer pulled-in the correct build of Chromium by default as its peer dependency. I wonder if the xvfb APT package (and its xvfb-run executable) would trigger an environment / platform detection in Puppeteer, causing it to choose the appropriate Chromium build in its postinstall step?

@josteinaj
Copy link
Member Author

I tried installing xvfb and running all the yarn-commands through xvfb-run now, but I get the same error.

@josteinaj
Copy link
Member Author

In the Dockerfile in this PR, the ace source code is added before installing chromium. That way, when the ace code changes, the latest version of chromium will be installed through apt-get.

@josteinaj
Copy link
Member Author

I rabased onto master now. Same behavior.

@danielweck
Copy link
Member

Note that Puppeteer v20 switched to Chrome instead of Chromium, but Ace remains on an older version due to other breaking changes that make it impossible to upgrade at this moment in time:
https://github.com/puppeteer/puppeteer/releases/tag/puppeteer-v20.0.0

@danielweck
Copy link
Member

Let's keep this ace-http Docker PR open for now, but see #392 (comment) for further information about headless Puppeteer vs. Electron

@danielweck danielweck changed the title added Dockerfile and .dockerignore Ace HTTP CLI Dockerfile and .dockerignore Jun 25, 2024
@danielweck danielweck marked this pull request as draft September 16, 2024 09:40
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

Successfully merging this pull request may close these issues.

Docker image
2 participants