raiguard / fmm

A portable CLI tool for managing your Factorio mods.
MIT License
25 stars 1 forks source link

Using fmm on a headless (docker) server without the correct file structure. #6

Closed MightyPiggie closed 7 months ago

MightyPiggie commented 9 months ago

So I am trying to get my Factorio server working with a Docker. To download the mods I wanted to use your application but unfortunately it seems to not work on a headless server.

At first it was giving me errors about not able to find the data and base folder which I tracked down to this line. It makes sense that these files don't exist since its not a full game. After removing these folders and recompiling. It almost seems like it would work, however now it seems to give me an error that does not make sense to me:

./fmm1 sync saves/Train\ world.zip 
disabled all mods
fetching info for base
no compatible release was found
fetching info for WireShortcuts
fetching info for aai-signals
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x653853]

goroutine 1 [running]:
github.com/raiguard/fmm/lib.(*PortalModRelease).compatibleWithBaseVersion(0xc0000b42c8?, 0xc0000a8200?)
        /tmp/fmm/lib/portal.go:215 +0x33
github.com/raiguard/fmm/lib.(*ModPortal).GetMatchingRelease(0xc0000b42c8, 0xc0004c3b40)
        /tmp/fmm/lib/portal.go:72 +0xbc
github.com/raiguard/fmm/lib.(*Manager).ExpandDependencies(0xc0000b42c0, {0xc0000d2840, 0x1d, 0x492ce0?}, 0x1)
        /tmp/fmm/lib/manager.go:420 +0x4c5
github.com/raiguard/fmm/cli.add(0x751b20?, {0xc00009c0e0?, 0xc0000ffd50?, 0x1?})
        /tmp/fmm/cli/cli.go:87 +0x4d
github.com/raiguard/fmm/cli.sync(0xc0000b42c0, {0xc00009c0e0, 0x1, 0x1})
        /tmp/fmm/cli/cli.go:164 +0x12a
github.com/raiguard/fmm/cli.Run({0xc00009c0d0, 0x2, 0x2})
        /tmp/fmm/cli/cli.go:79 +0x65c
main.main()
        /tmp/fmm/main.go:10 +0x45

While writing this I figured out what the problem was. I miss understood why you need the info.json file. After adding this in the correct path (data/base/info.json) and copy pasting the content from my pc, everything worked correctly. I was able to sync the mods with the save. Even though this is not really a bug I think it could still be useful for other people trying to use this on a headless server so I'll post it here anyways until it has been officially implemented.

Thanks for this amazing tool (And for the latest blog post/additions to the mod manager for update 2.0 :) )

raiguard commented 9 months ago

How are you setting up this server? If the game doesn't have the data/base then it means it's missing the core content of the game and shouldn't be able to run.

If the headless server is using different directories for the game installation and the "user data" (saves, mods, user scenarios, etc), then this is a known issue that I need to fix.

MightyPiggie commented 9 months ago

Mmmh good question. I am pretty sure it wasn't in the same docker volume as the save file. And since it couldn't find it I assume it's also not in the default .Factorio directory. I will go and take a look on my server to see if I can find it anymore. I'll let you know once I found some more information

MightyPiggie commented 9 months ago

Mmmmh. I am sure there isn't a data/base included within the factorio folder. However, it is included within the docker. If I do a find / -wholename "*data/base" I will find results about factorio:

/var/lib/docker/overlay2/95bgybebrovbmqeovwox6nh4m/diff/opt/factorio/data/base
/var/lib/docker/overlay2/a5ae5408fa94f6b237693f6010d56892dc26723da9014f1ca1a1fb75c1583a46/merged/opt/factorio/data/base
/var/lib/docker/overlay2/de41622c25a401a50bfd6cdd6e2f44f0a9c2356ded5c0cb9d9bf5abf67bd7d74/diff/opt/factorio/data/base

Same result if I do a sudo find / -wholename "*factorio/bin/x64":

/var/lib/docker/overlay2/95bgybebrovbmqeovwox6nh4m/diff/opt/factorio/bin/x64
/var/lib/docker/overlay2/a5ae5408fa94f6b237693f6010d56892dc26723da9014f1ca1a1fb75c1583a46/merged/opt/factorio/bin/x64
/var/lib/docker/overlay2/de41622c25a401a50bfd6cdd6e2f44f0a9c2356ded5c0cb9d9bf5abf67bd7d74/diff/opt/factorio/bin/x64

I am honestly not sure if this is default behavior for docker or if this is an upstream issue.

matya commented 9 months ago

So I am trying to get my Factorio server working with a Docker.

What do you mean with a Docker? Docker uses container images, so unless you are building it from scratch, there is some content in the container, which apparently already has a factorio installation, as mentioned above.

I think you should be able to use it if you do an export FACTORIO_PATH=/opt/factorio.

If not, you can use docker run --rm -ti --entrypoint /bin/bash <docker_image_name> do explore around inside the container and use ls -l or find /opt/factiorio -type d -ls to check the content.

MightyPiggie commented 9 months ago

What do you mean with a Docker? Docker uses container images, so unless you are building it from scratch, there is some content in the container, which apparently already has a factorio installation, as mentioned above.

Yeah I am trying to use a Factorio image. To be specific I use docker-compose with the volume mounted to /opt/factorio. Shouldn't this place thedata/base folder within the /opt/factorio path just like it did with all the save files, mods and config files?

I think you should be able to use it if you do an export FACTORIO_PATH=/opt/factorio.

Thats not the problem here, the docker image doesn't even use FACTORIO_PATH. The only thing it uses is the FACTORIO_VOL and this is already set in the docker-entrypoint.sh

matya commented 9 months ago

as far I could see that image puts the original factorio headless server to /opt/factorio.

The volume your container is supposed to receive is set as /factorio (without the /opt), as it is defined in the docker-compose yaml file, as it maps the outside /opt/factorio to the inside /factorio, providing you persistent data storage for your things.

The mentioned entrypoint moves all the directories the game writes to /factorio as detailed in the docs.

What you could do is execute fmm in the directory of /opt/factorio, or set the FACTORIO_PATH=/opt/factorio as it ... "_will check the current directory and the previous directory for a Factorio installation. If neither is valid, it will fall back to the directory specified by the FACTORIOPATH environment variable."

I am still quite sure you have that directory with the complete game installation there in your container, since it's required to run the game. Bottom line is that I don't think you need to recompile it.

@raiguard Sorry for just crashing in to this ticket, I was just exploring the project and thought I could help out with this question 😄

MightyPiggie commented 9 months ago

What you could do is execute fmm in the directory of /opt/factorio, or set the FACTORIO_PATH=/opt/factorio as it ... "_will check the current directory and the previous directory for a Factorio installation. If neither is valid, it will fall back to the directory specified by the FACTORIOPATH environment variable."

Well that's the first thing I tried with fmm however since it missed the data/base folder I got the above errors. As you can see in my previous messages when I tried to search for the data/base folder you can see they are definitely not inside the opt/factorio or inside the /factorio folder.

raiguard commented 7 months ago

I have added a new config variable FACTORIO_MODS_PATH that allows specifying the mods directory separate from the game directory. Sorry for the wait!

In your case you would specify FACTORIO_PATH=/opt/factorio and FACTORIO_MODS_PATH=/factorio/mods.