docker-palworld-dedicated-server icon indicating copy to clipboard operation
docker-palworld-dedicated-server copied to clipboard

Properly auto-detect `PUBLIC_IP` when omitting from docker-compose.yml

Open Jarvl opened this issue 1 year ago • 3 comments

Have you read the Important information text above

  • [X] Yes i did

Current behavior

When omitting PUBLIC_IP from docker-compose.yml, it is not auto-detected and instead the PublicIp value in /game/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini set to 10.0.0.1.

For users, it is a bit hard to follow what the actual behavior of the container will be since the docs for PUBLIC_IP contradicts itself by stating auto-detect if not specified while also stating that the default value is 10.0.0.1. No auto-detection is taking place.

Desired behavior

Proper auto-detection of PUBLIC_IP

Two steps to this below.

Remove default value for PUBLIC_IP

Remove 10.0.0.1 as the default value from Dockerfile: https://github.com/jammsen/docker-palworld-dedicated-server/blob/ee23b8807b280d2787af71ab18cfb7a0cc51b577/Dockerfile#L16

Reasons for this:

  1. 10.0.0.1 is slightly misleading as a default PUBLIC_IP since the 10.0.0.0/8 IP ranges are specially reserved for private networks. It's not a sensible default. In general, there really is no sensible default for PUBLIC_IP, which is why I'm opting for it to be removed as a default entirely.
  2. Omitting PUBLIC_IP will line up with the Setup for community server. instructions:

You can manually specify the global IP address of the network on which the server running. If not specified, it will be detected automatically. If it does not work well, try manual configuration.

  1. Instead of defining a default, the value can be dynamically populated when the container starts (see below).

Allow PUBLIC_IP to be detected and set dynamically

Add ability to set PUBLIC_IP environment variable to auto and make this the default value/behavior as currently noted in the README. This will automatically detect the network's public IP and set it in the game config. This is particularly useful for networks that do not have static IPs, as it removes the manual effort of reflecting changes to the public IP in docker-compose.yml. Even for networks with static IPs, it removes a manual step in the initial setup process.

General flow can go like this:

  1. Container is started and servermanager.sh script is run.
  2. startServer() is called and checks if PUBLIC_IP is either not set or set to the string auto.
  • If either of these expressions are true, execute command curl ifconfig.me to retrieve public IP address and replace PublicIp config value with this IP in /game/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini.
  • If something other than auto is defined for PUBLIC_IP, use that for the PublicIp config value.

Links to screenshots

No response

To Reproduce

Steps to reproduce the behavior:

  1. Fresh clone or install of the repo, or remove cached images for the docker-compose project and set PublicIp to "" in game/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini.
  2. Remove PUBLIC_IP env variable from docker-compose.yml
  3. docker-compose up -d wait for server to start (monitor with docker-compose logs -f)
  4. Run command cat /game/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini (or wherever your config file is located), PublicIp will have been overridden to 10.0.0.1.

Software setup

  • OS: Slackware 15.0 x86_64 (post 15.0 -current)
    • i.e. Unraid 6.12.6
  • Docker: Docker version 20.10.24, build 297e128

Hardware setup

  • vCPU: 12
  • RAM: 104 GiB
  • Disk: 1 TB

Additional context

I'm happy to write a PR for this but I wanted to get your input beforehand.

Jarvl avatar Jan 22 '24 20:01 Jarvl

Hey @Jarvl What you need to set is:

    environment:
      ...
      - PUBLIC_IP=
      - PUBLIC_PORT=8211
      ...

This works flawless, when i just tested this. Of course the default set of the Dockerfile will be used when you dont set something else in Docker-Compose, thats suppose to happen.

jammsen avatar Jan 22 '24 23:01 jammsen

@Jarvl Did this help?

jammsen avatar Jan 23 '24 10:01 jammsen

Please keep in mind that the community server search is limited to 200. It querys only the 200 search entrys, so you may need to load the next 200 entrys (bottom right Button). This is a known bug in Palworld.

lordimac avatar Jan 24 '24 12:01 lordimac

This issue should be solved

jammsen avatar Jan 25 '24 20:01 jammsen