ArnoldSmith86 / virtualtabletop

a virtual surface in the browser on which you can play board, dice and card games
https://virtualtabletop.io
GNU General Public License v3.0
173 stars 31 forks source link

Docker-compose ERR_MODULE_NOT_FOUND #2357

Open goaliedude3919 opened 2 weeks ago

goaliedude3919 commented 2 weeks ago

I'm trying to run this in Docker and tried following the instructions in the Wiki (https://github.com/ArnoldSmith86/virtualtabletop/wiki/Docker)

I use Dockge to manage my docker containers, to I tried following the instructions under "Developing virtualtabletop in a container". When I try to start the container, I get the following error:

Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'express' imported from /home/node/app/server.mjs
    at new NodeError (node:internal/errors:400:5)
    at packageResolve (node:internal/modules/esm/resolve:823:9)
    at moduleResolve (node:internal/modules/esm/resolve:872:20)
    at defaultResolve (node:internal/modules/esm/resolve:1087:11)
    at nextResolve (node:internal/modules/esm/loader:161:28)
    at ESMLoader.resolve (node:internal/modules/esm/loader:834:30)
    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:415:18)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:77:40)
    at link (node:internal/modules/esm/module_job:76:36) {
  code: 'ERR_MODULE_NOT_FOUND'
ArnoldSmith86 commented 2 weeks ago

Are you getting more output than that? Because the container should execute this:

    command: sh -c "npm i; NOCOMPRESS=1 npx nodemon -e js,mjs,css,html,json --ignore save/ --ignore coverage/ --ignore tests/ --inspect server.mjs"

The first part is npm i, which should install the requirements. That doesn't seem to be working. Maybe your container can't reach the internet?

goaliedude3919 commented 2 weeks ago

Are you getting more output than that? Because the container should execute this:

    command: sh -c "npm i; NOCOMPRESS=1 npx nodemon -e js,mjs,css,html,json --ignore save/ --ignore coverage/ --ignore tests/ --inspect server.mjs"

The first part is npm i, which should install the requirements. That doesn't seem to be working. Maybe your container can't reach the internet?

Here's the logging that I see in Dozzle: vtt-log.txt

goaliedude3919 commented 2 weeks ago

Here's a log from the filesystem that has an error in it. vtt-log2.txt

ArnoldSmith86 commented 2 weeks ago

I don't have much experience with docker-compose. The Dockerfile at the top of the page is more meant as actual hosting and not developing. I asked Claude (AI) to turn it into a docker-compose file. Maybe you have more luck with that:

services:
  vtt:
    image: node:18-alpine
    ports:
      - "8272:8272"
    volumes:
      - ./save:/virtualtabletop-main/save
    working_dir: /virtualtabletop-main
    command: npm start
    entrypoint: >
      sh -c "
        apk add --no-cache curl unzip &&
        curl -LO https://github.com/ArnoldSmith86/virtualtabletop/archive/refs/heads/main.zip &&
        unzip main.zip &&
        rm main.zip &&
        apk del curl unzip &&
        cd virtualtabletop-main &&
        npm install --prod &&
        exec npm start
      "

There are also some images in the docker hub: https://hub.docker.com/search?q=virtualtabletop but they don't seem to get updated. Never tried any of them.


In general your error messages seem to be permission problems on the host filesystem though. Maybe take a look at that.

goaliedude3919 commented 1 week ago

I don't have much experience with docker-compose. The Dockerfile at the top of the page is more meant as actual hosting and not developing. I asked Claude (AI) to turn it into a docker-compose file. Maybe you have more luck with that:

services:
  vtt:
    image: node:18-alpine
    ports:
      - "8272:8272"
    volumes:
      - ./save:/virtualtabletop-main/save
    working_dir: /virtualtabletop-main
    command: npm start
    entrypoint: >
      sh -c "
        apk add --no-cache curl unzip &&
        curl -LO https://github.com/ArnoldSmith86/virtualtabletop/archive/refs/heads/main.zip &&
        unzip main.zip &&
        rm main.zip &&
        apk del curl unzip &&
        cd virtualtabletop-main &&
        npm install --prod &&
        exec npm start
      "

There are also some images in the docker hub: https://hub.docker.com/search?q=virtualtabletop but they don't seem to get updated. Never tried any of them.

In general your error messages seem to be permission problems on the host filesystem though. Maybe take a look at that.

Looks like that got the container working, but it looks like none of the buttons are loading or something? There's some weird secondary text on top of all the buttons.

image

ArnoldSmith86 commented 1 week ago

Then the externalURL in config.json is wrong.

goaliedude3919 commented 1 week ago

Then the externalURL in config.json is wrong.

So one change I made to the compose file was to make the volume /opt/apps/vtt/save:/virtualtabletop-main/save. When doing this I didn't see anything on the filesystem other than an empty save folder. So I tried adding another volume of /opt/apps/vtt:/virtualtabletop-main. This created a folder under vtt called virtualtabletop-main where I can find a config.json file, but I can no longer access the webpage when adding that volume.