BenjaminPrice / fvtt-docker

Foundry VTT - Docker
MIT License
31 stars 38 forks source link

Foundry Unable to Start - Errors During Unzip #33

Closed tadi1 closed 8 months ago

tadi1 commented 2 years ago

Hello,

I'm currently having trouble getting the container to start up since pulling the latest image. Previously, I was on a version of the image from 2022-01-26 (image does not have a tag) without issue, but since updating the image and the yml file to the new specs, I've been unable to get the container to start. I've even tried running a new version of the container. The below details are all from the new container.

I originally configured this container using the guidance of https://github.com/marcwagner/foundry_swag_docker but have since modified the docker-compose.yml to match the changes made to the image about 10 days ago.

Relevant portion of the docker-compose.yml (really the stack config in portainer):

version: "3.8"
services:
  foundry:
    container_name: foundryCurrent
    hostname: foundry
    image: direckthit/fvtt-docker:latest
    expose:
      - 30000
    volumes:
      - /dockerVolumes/foundryCurrent/data:/data/foundryvtt     # replace with the correct path to your foundry config dir
      - /dockerVolumes/foundryCurrent/downloads:/host                     # replace with the correct path to your foundry-x.x.x.zip file
    restart: unless-stopped

Log snippet - this repeats continuously. The container is unable to extract to /opt/foundryvtt/resources/app/common/ but from what I've been able to decipher from run-server.sh, it should be able to

2022-08-19T03:04:39.141149844Z Archive:  foundryvtt-9.266.zip
2022-08-19T03:04:42.093754836Z   inflating: LICENSE.electron.txt
2022-08-19T03:04:42.093776611Z   inflating: LICENSES.chromium.html
2022-08-19T03:04:42.093783322Z   inflating: chrome-sandbox
2022-08-19T03:04:42.093788556Z   inflating: chrome_100_percent.pak
2022-08-19T03:04:42.093793366Z   inflating: chrome_200_percent.pak
2022-08-19T03:04:42.093798152Z   inflating: chrome_crashpad_handler
2022-08-19T03:04:42.093802921Z   inflating: foundryvtt
2022-08-19T03:04:42.093807426Z   inflating: icudtl.dat
2022-08-19T03:04:42.093811900Z   inflating: libEGL.so
2022-08-19T03:04:42.093816589Z   inflating: libGLESv2.so
2022-08-19T03:04:42.093821572Z   inflating: libffmpeg.so
2022-08-19T03:04:42.093826333Z   inflating: libvk_swiftshader.so
2022-08-19T03:04:42.093831036Z   inflating: libvulkan.so.1
2022-08-19T03:04:42.093835717Z   inflating: locales/am.pak
2022-08-19T03:04:42.093840435Z   inflating: locales/ar.pak
2022-08-19T03:04:42.093845173Z   inflating: locales/bg.pak
2022-08-19T03:04:42.093849907Z   inflating: locales/bn.pak
2022-08-19T03:04:42.093854705Z   inflating: locales/ca.pak
2022-08-19T03:04:42.093859652Z   inflating: locales/cs.pak
2022-08-19T03:04:42.093864534Z   inflating: locales/da.pak
2022-08-19T03:04:42.093869324Z   inflating: locales/de.pak
2022-08-19T03:04:42.093874595Z   inflating: locales/el.pak
2022-08-19T03:04:42.093879335Z   inflating: locales/en-GB.pak
2022-08-19T03:04:42.093884072Z   inflating: locales/en-US.pak
2022-08-19T03:04:42.093888848Z   inflating: locales/es-419.pak
2022-08-19T03:04:42.093893592Z   inflating: locales/es.pak
2022-08-19T03:04:42.093898432Z   inflating: locales/et.pak
2022-08-19T03:04:42.093903159Z   inflating: locales/fa.pak
2022-08-19T03:04:42.093907691Z   inflating: locales/fi.pak
2022-08-19T03:04:42.093921738Z   inflating: locales/fil.pak
2022-08-19T03:04:42.093927141Z   inflating: locales/fr.pak
2022-08-19T03:04:42.093931909Z   inflating: locales/gu.pak
2022-08-19T03:04:42.093936547Z   inflating: locales/he.pak
2022-08-19T03:04:42.093941172Z   inflating: locales/hi.pak
2022-08-19T03:04:42.093946124Z   inflating: locales/hr.pak
2022-08-19T03:04:42.217049921Z unzip: can't create directory 'resources/app/common/': Permission denied
2022-08-19T03:04:42.217050065Z   inflating: locales/hu.pak
2022-08-19T03:04:42.217085832Z   inflating: locales/id.pak
2022-08-19T03:04:42.217089479Z   inflating: locales/it.pak
2022-08-19T03:04:42.217092980Z   inflating: locales/ja.pak
2022-08-19T03:04:42.217096444Z   inflating: locales/kn.pak
2022-08-19T03:04:42.217099967Z   inflating: locales/ko.pak
2022-08-19T03:04:42.217103279Z   inflating: locales/lt.pak
2022-08-19T03:04:42.217106608Z   inflating: locales/lv.pak
2022-08-19T03:04:42.217110003Z   inflating: locales/ml.pak
2022-08-19T03:04:42.217113314Z   inflating: locales/mr.pak
2022-08-19T03:04:42.217116587Z   inflating: locales/ms.pak
2022-08-19T03:04:42.217119849Z   inflating: locales/nb.pak
2022-08-19T03:04:42.217123100Z   inflating: locales/nl.pak
2022-08-19T03:04:42.217126522Z   inflating: locales/pl.pak
2022-08-19T03:04:42.217129795Z   inflating: locales/pt-BR.pak
2022-08-19T03:04:42.217133061Z   inflating: locales/pt-PT.pak
2022-08-19T03:04:42.217136526Z   inflating: locales/ro.pak
2022-08-19T03:04:42.217139905Z   inflating: locales/ru.pak
2022-08-19T03:04:42.217143148Z   inflating: locales/sk.pak
2022-08-19T03:04:42.217146406Z   inflating: locales/sl.pak
2022-08-19T03:04:42.217149644Z   inflating: locales/sr.pak
2022-08-19T03:04:42.217153008Z   inflating: locales/sv.pak
2022-08-19T03:04:42.217156311Z   inflating: locales/sw.pak
2022-08-19T03:04:42.217159542Z   inflating: locales/ta.pak
2022-08-19T03:04:42.217162784Z   inflating: locales/te.pak
2022-08-19T03:04:42.217166005Z   inflating: locales/th.pak
2022-08-19T03:04:42.217169236Z   inflating: locales/tr.pak
2022-08-19T03:04:42.217172460Z   inflating: locales/uk.pak
2022-08-19T03:04:42.217175709Z   inflating: locales/vi.pak
2022-08-19T03:04:42.217179059Z   inflating: locales/zh-CN.pak
2022-08-19T03:04:42.217182320Z   inflating: locales/zh-TW.pak
2022-08-19T03:04:42.217185561Z   inflating: resources.pak
2022-08-19T03:04:42.217188844Z    creating: resources/app/common/
2022-08-19T03:04:42.262281839Z node:internal/modules/cjs/loader:936
2022-08-19T03:04:42.262322595Z   throw err;
2022-08-19T03:04:42.262327382Z   ^
2022-08-19T03:04:42.262330790Z 
2022-08-19T03:04:42.262334425Z Error: Cannot find module '/opt/foundryvtt/resources/app/main.js'
2022-08-19T03:04:42.262338045Z     at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
2022-08-19T03:04:42.262341560Z     at Function.Module._load (node:internal/modules/cjs/loader:778:27)
2022-08-19T03:04:42.262345053Z     at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
2022-08-19T03:04:42.262348604Z     at node:internal/main/run_main_module:17:47 {
2022-08-19T03:04:42.262352057Z   code: 'MODULE_NOT_FOUND',
2022-08-19T03:04:42.262355400Z   requireStack: []
2022-08-19T03:04:42.262358789Z }
2022-08-19T03:05:42.832445995Z Archive:  foundryvtt-9.266.zip

Any help that you're able to provide is appreciated.

shukerrjp commented 2 years ago

I am also encountering this error after following the setup from this guide: https://benprice.dev/posts/fvtt-docker-tutorial/

tadi1 commented 2 years ago

So I created a locally modified image to poke around with this. I wanted to monitor the contents of /opt/foundryvtt while potentially making other changes and for some reason the container started working once I applied the new image. Before this unexpectedly started to work, I was hoping to modify run-server.sh to unzip the file, setting the owner on newly created folders to the current user, fvtt (I'm not currently sure why this wasn't already the case - the resources folder was owned by root).

#!/bin/sh

# look for a file name foundryvtt-.....zip or FoundryVTT...zip, copy it to 
# /opt/foundryvtt, unzip and remove it. Then start the foundry app

whoami
cd /opt/foundryvtt
find /host -type f -name [f,F]oundry[vtt,VTT]*.zip -exec cp '{}' . ';'
ls -al /opt/foundryvtt
unzip -o *.zip && rm *.zip
node resources/app/main.js --dataPath=/data/foundryvtt
FROM node:16-alpine

RUN deluser node && \
    mkdir /opt/foundryvtt && \
    mkdir /data && \
    mkdir /data/foundryvtt && \
    adduser --disabled-password fvtt && \
    chown fvtt:fvtt /opt/foundryvtt && \
    chown fvtt:fvtt /data/foundryvtt && \
    chmod g+s /opt/foundryvtt && \
    chmod g+s /data/foundryvtt
USER fvtt

COPY --chown=fvtt run-server.sh /opt/foundryvtt
RUN chmod +x /opt/foundryvtt/run-server.sh
VOLUME /data/foundryvtt
VOLUME /host
VOLUME /opt/foundryvtt/app
VOLUME /opt/foundryvtt
EXPOSE 30000

ENTRYPOINT /opt/foundryvtt/run-server.sh
Trashloot commented 2 years ago

So I created a locally modified image to poke around with this. I wanted to monitor the contents of /opt/foundryvtt while potentially making other changes and for some reason the container started working once I applied the new image. Before this unexpectedly started to work, I was hoping to modify run-server.sh to unzip the file, setting the owner on newly created folders to the current user, fvtt (I'm not currently sure why this wasn't already the case - the resources folder was owned by root).

#!/bin/sh

# look for a file name foundryvtt-.....zip or FoundryVTT...zip, copy it to 
# /opt/foundryvtt, unzip and remove it. Then start the foundry app

whoami
cd /opt/foundryvtt
find /host -type f -name [f,F]oundry[vtt,VTT]*.zip -exec cp '{}' . ';'
ls -al /opt/foundryvtt
unzip -o *.zip && rm *.zip
node resources/app/main.js --dataPath=/data/foundryvtt
FROM node:16-alpine

RUN deluser node && \
    mkdir /opt/foundryvtt && \
    mkdir /data && \
    mkdir /data/foundryvtt && \
    adduser --disabled-password fvtt && \
    chown fvtt:fvtt /opt/foundryvtt && \
    chown fvtt:fvtt /data/foundryvtt && \
    chmod g+s /opt/foundryvtt && \
    chmod g+s /data/foundryvtt
USER fvtt

COPY --chown=fvtt run-server.sh /opt/foundryvtt
RUN chmod +x /opt/foundryvtt/run-server.sh
VOLUME /data/foundryvtt
VOLUME /host
VOLUME /opt/foundryvtt/app
VOLUME /opt/foundryvtt
EXPOSE 30000

ENTRYPOINT /opt/foundryvtt/run-server.sh

Hi :D.

Im a complete docker noob and i just used this image because a guide told me to. Can you maybe tell me where you made those changes ? I would love to get my foundry back up and working again.

AithanIT commented 2 years ago

I am also having the same issue, any help would be greatly appreciated.

AithanIT commented 2 years ago

I found a workaround for the Portainer + Traefik tutorial: you need to add a third volume, with /opt/foundryvtt/resources/app as the path in container and something like /home/username/foundryapp for the host. The Readme on github claims it's only necessary for custom login screens, but if you add the volume in Portainer (or in the compose, I assume) it works perfectly.

adkeeney commented 2 years ago

I found a workaround for the Portainer + Traefik tutorial: you need to add a third volume, with /opt/foundryvtt/resources/app as the path in container and something like /home/username/foundryapp for the host. The Readme on github claims it's only necessary for custom login screens, but if you add the volume in Portainer (or in the compose, I assume) it works perfectly.

Hmm. Tried to do this via the fvtt container but it did not function for me. Need to be added in the portainer docker-compose.yaml file?

adkeeney commented 2 years ago

Yeah, I'm not sure what is going on. I'm not well versed in docker. Getting these errors from the Portainer fvtt container log:

inflating: resources.pak creating: resources/app/client/ unzip: can't create directory 'resources/app/client/': Permission denied node:internal/modules/cjs/loader:936
throw err; ^ Error: Cannot find module '/opt/foundryvtt/resources/app/main.js' at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15) at Function.Module._load (node:internal/modules/cjs/loader:778:27) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12) at node:internal/main/run_main_module:17:47 { code: 'MODULE_NOT_FOUND', requireStack: []

AithanIT commented 2 years ago

I found a workaround for the Portainer + Traefik tutorial: you need to add a third volume, with /opt/foundryvtt/resources/app as the path in container and something like /home/username/foundryapp for the host. The Readme on github claims it's only necessary for custom login screens, but if you add the volume in Portainer (or in the compose, I assume) it works perfectly.

Hmm. Tried to do this via the fvtt container but it did not function for me. Need to be added in the portainer docker-compose.yaml file?

No, I just used the GUI from Portainer. You basically need to create a folder such as /home/USERNAME/foundryapp (the name of the folder isn't important, but you need to make it beforehand and make it with your user, not root, otherwise Docker won't have the permissions to write in it), and /opt/foundryvtt/resources/app as the path in container. That worked for me. I was getting the same errors as you are beforehand, so that should work.

adkeeney commented 2 years ago

I found a workaround for the Portainer + Traefik tutorial: you need to add a third volume, with /opt/foundryvtt/resources/app as the path in container and something like /home/username/foundryapp for the host. The Readme on github claims it's only necessary for custom login screens, but if you add the volume in Portainer (or in the compose, I assume) it works perfectly.

Hmm. Tried to do this via the fvtt container but it did not function for me. Need to be added in the portainer docker-compose.yaml file?

No, I just used the GUI from Portainer. You basically need to create a folder such as /home/USERNAME/foundryapp (the name of the folder isn't important, but you need to make it beforehand and make it with your user, not root, otherwise Docker won't have the permissions to write in it), and /opt/foundryvtt/resources/app as the path in container. That worked for me. I was getting the same errors as you are beforehand, so that should work.

Edit: started with fresh container and this worked. Thanks so much for the help!

AlexG2490 commented 2 years ago

I found a workaround for the Portainer + Traefik tutorial: you need to add a third volume, with /opt/foundryvtt/resources/app as the path in container and something like /home/username/foundryapp for the host. The Readme on github claims it's only necessary for custom login screens, but if you add the volume in Portainer (or in the compose, I assume) it works perfectly.

Hmm. Tried to do this via the fvtt container but it did not function for me. Need to be added in the portainer docker-compose.yaml file?

No, I just used the GUI from Portainer. You basically need to create a folder such as /home/USERNAME/foundryapp (the name of the folder isn't important, but you need to make it beforehand and make it with your user, not root, otherwise Docker won't have the permissions to write in it), and /opt/foundryvtt/resources/app as the path in container. That worked for me. I was getting the same errors as you are beforehand, so that should work.

I am having the exact same issues but this doesn't seem to be working for me. Just to be sure I have all this right:

  1. SSH into the box as root, change user to the user account for fvtt, and create home/USERNAME/foundryapp
  2. Edit fvtt container
  3. Make a volume in fvtt in Portainer with BIND instead of VOLUME type, where "host" = "/home/username/foundryapp" and "path in container" = "/opt/foundryvtt/resources/app"
  4. Replace the container when asked if it is OK to replace the container that already exists with the same name
  5. Put the new Foundry ZIP in foundrydl directory and rename to use all lowercase characters instead of mixed case
  6. Recreate container pulling the latest image
  7. Start the container

Anything I missed or did wrong? I am still getting the error about not being able to find the module "/opt/foundryvtt/resources/app/main.js" and either a 404 or a Bad Gateway error.

I checked the foundryapp directory via FTP and nothing seems to be written there. I even changed permissions to allow public users to write to it but it still doesn't seem to work. I am sure I have missed something stupid and simple but I can't see what.

vonundzuBergen commented 2 years ago

@AlexG2490 Changing the permissions to all three directories bound to the container did the trick for me. I used chmod 777 for testing purposes, but didn't have time to find a more restrictive setup which still allows the container to do its thing.

rdonohue commented 1 year ago

Spent some time staring at this for a while.

Seems like there's a discrepancy with the USER 'fvtt' chmod access in the Dockerfile that prevents the created user 'fvtt' from unzipping due to being unable to write to the directory linked with docker at home/$USER/foundryapp:/opt/foundryvtt/resources/app.

FROM node:16-alpine

RUN deluser node && \
    mkdir /opt/foundryvtt && \
    mkdir /data && \
    mkdir /data/foundryvtt && \
    adduser --disabled-password fvtt && \
    ### chown fvtt:fvtt /opt/foundryvtt && \
    ### chown fvtt:fvtt /data/foundryvtt && \
    ### chmod g+s /opt/foundryvtt && \
    ### chmod g+s /data/foundryvtt
USER fvtt

COPY --chown=fvtt run-server.sh /opt/foundryvtt
RUN chmod +x /opt/foundryvtt/run-server.sh
VOLUME /data/foundryvtt
VOLUME /host
### VOLUME /opt/foundryvtt/resources/app
EXPOSE 30000

ENTRYPOINT /opt/foundryvtt/run-server.sh

I've denoted my suspected lines with three # above.

I think this can be remedied by adding a chmod g+s command for the new volume so the directory can be referenced properly by 'fvtt' user, or if it's not breaking anything, remove the third volume entirely.

Not sure if this helps. I may try to get a fix if it's needed for a PR, but by all means someone post a fix if you have it. I don't have anything set up to test yet.

powercore2000 commented 1 year ago

I've just had this exact same issue. I managed to fix it by changing the ownership of the created files to the user, instead of the root. A more permanent solution is probably modifying the sh file like @rdonohue recommended.

Trashloot commented 1 year ago

I've just had this exact same issue. I managed to fix it by changing the ownership of the created files to the user, instead of the root. A more permanent solution is probably modifying the sh file like @rdonohue recommended.

Can you please tell me how you changed the ownership ? Im a total noob when it comes to this whole topic. I solved this issue here by just using an old image and just waiting for a fixed version. But i kinda wan't to know how to change file and folder ownership anyways. I tried learning it on my own but im just confused.

uiiu10 commented 1 year ago

I've just had this exact same issue. I managed to fix it by changing the ownership of the created files to the user, instead of the root. A more permanent solution is probably modifying the sh file like @rdonohue recommended.

Can you please tell me how you changed the ownership ? Im a total noob when it comes to this whole topic. I solved this issue here by just using an old image and just waiting for a fixed version. But i kinda wan't to know how to change file and folder ownership anyways. I tried learning it on my own but im just confused.

even more noob question: how do i use an old image?

Trashloot commented 1 year ago

I've just had this exact same issue. I managed to fix it by changing the ownership of the created files to the user, instead of the root. A more permanent solution is probably modifying the sh file like @rdonohue recommended.

Can you please tell me how you changed the ownership ? Im a total noob when it comes to this whole topic. I solved this issue here by just using an old image and just waiting for a fixed version. But i kinda wan't to know how to change file and folder ownership anyways. I tried learning it on my own but im just confused.

even more noob question: how do i use an old image?

I was kinda hoping that someone would answer your question. I simply restored everything to a backup of the server where the old image was still in use.

4cer commented 1 year ago

Can you please tell me how you changed the ownership ? Im a total noob when it comes to this whole topic.

To recursively set ownership in Linux use the following command: chown [USER]:[GROUP] [directory containing your foundry data] -R

For instance, as a user called tango, I used docker compose with following bindings: /home/tango/foundry/data:/data/foundryvtt /home/tango/foundry/core:/opt/foundryvtt/resources/app

After executing compose, the data got placed on the host system in directories left side of the colons, but their owner is the user root and group root. This introduces the need to use elevated permissions, so we need to prefix the command with sudo. To take ownership of those directories I would need to execute the following: sudo chown tango:tango /home/tango/foundry/* -R

redredkrovy commented 1 year ago

Had the same issue. Using the chmod 777 -R command on the foundry directory fixed it. Definitely a permission issue.

DFreds commented 8 months ago

Still having the same issue even after doing everything here. Any other ideas?

AithanIT commented 8 months ago

Still having the same issue even after doing everything here. Any other ideas?

I'm sorry, I kinda gave up with the whole project and I'm now using Caddy as a reverse Proxy. I've decided that this setup might be a bit overkill for what I was trying to accomplish so I switched to something more lightweight.