gildas-lormeau / single-file-cli

CLI tool for saving a faithful copy of a complete web page in a single HTML file (based on SingleFile)
GNU Affero General Public License v3.0
594 stars 63 forks source link

docker image built manually does not work #123

Open hugo-akaora opened 3 days ago

hugo-akaora commented 3 days ago

Hello,

I built properly single-file-cli under arm64 raspberry:

# git clone --depth 1 --recursive https://github.com/gildas-lormeau/single-file-cli.git
# cd single-file-cli
# docker build --no-cache -t singlefile .
[+] Building 26.1s (7/7) FINISHED                                                                                                                                               docker:default
 => [internal] load build definition from Dockerfile                                                                                                                                      0.3s
 => => transferring dockerfile: 362B                                                                                                                                                      0.0s
 => [internal] load metadata for docker.io/zenika/alpine-chrome:with-node                                                                                                                 0.6s
 => [internal] load .dockerignore                                                                                                                                                         0.3s
 => => transferring context: 2B                                                                                                                                                           0.0s
 => CACHED [1/3] FROM docker.io/zenika/alpine-chrome:with-node@sha256:dae38711b03ae344b29b4b63c32d15fab7a2c5cef40102855a3b874fc295baa2                                                    0.0s
 => [2/3] RUN npm install --omit=dev single-file-cli                                                                                                                                     21.7s
 => [3/3] WORKDIR /usr/src/app/node_modules/single-file-cli                                                                                                                               0.7s 
 => exporting to image                                                                                                                                                                    1.4s 
 => => exporting layers                                                                                                                                                                   1.1s 
 => => writing image sha256:df0a2936ef0e37b2ab90707484f0fe93e614330488c1306c02762d153e5af075                                                                                              0.0s 
 => => naming to docker.io/library/singlefile

Image is properly built.

But it seems that something is missing :

#:~/single-file-cli# docker run -v $(pwd):/usr/src/app/out docker.io/library/singlefile "https://www.wikipedia.org" --dump-content=false
node:internal/modules/cjs/loader:1148
  throw err;
  ^

Error: Cannot find module '/usr/src/app/node_modules/single-file-cli/single-file-node.js'
    at Module._resolveFilename (node:internal/modules/cjs/loader:1145:15)
    at Module._load (node:internal/modules/cjs/loader:986:27)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:174:12)
    at node:internal/main/run_main_module:28:49 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

Node.js v20.15.1

Did I forgot something?

Thank you, very nice addon!

gildas-lormeau commented 2 days ago

I updated the Docker file in order to use npx to launch single-file. Does this change impact your issue?

hugo-akaora commented 6 hours ago

Hello, now I don't have the same error with 2.0.64:

(node:17) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
(Use `node --trace-warnings ...` to show where the warning was created)
/usr/src/app/node_modules/single-file-cli/single-file-node.js:3
import { run } from "./single-file-launcher.js";
^^^^^^

SyntaxError: Cannot use import statement outside a module
    at wrapSafe (node:internal/modules/cjs/loader:1281:20)
    at Module._compile (node:internal/modules/cjs/loader:1321:27)
    at Module._extensions..js (node:internal/modules/cjs/loader:1416:10)
    at Module.load (node:internal/modules/cjs/loader:1208:32)
    at Module._load (node:internal/modules/cjs/loader:1024:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:174:12)
    at node:internal/main/run_main_module:28:49

Node.js v20.15.1
hugo-akaora commented 6 hours ago

Okay, I wasn't able to build it myself on Raspberry Pi, where as it seems that the fork https://github.com/jasongzy/single-file-cli is able to push the last version to Docker Hub on arch arm64. So I guess the code is okay