🎮

Palworld Server を Docker で立てる時メモ

2024/01/24に公開

簡単Ver

  1. PalServer フォルダを作って中に ↓ の Dockerfiledocker-compose.yml を作成する
mkdir PalServer
cd PalServer
Dockerfile
FROM steamcmd/steamcmd:debian-12 AS build

RUN steamcmd +login anonymous +app_update 2394010 validate +quit

FROM gcr.io/distroless/cc-debian12:nonroot AS base

COPY --from=build --chown=nonroot /root/.local/share/Steam/steamapps/common/PalServer/ PalServer/
COPY --from=build /root/.steam/sdk64/steamclient.so .steam/sdk64/

EXPOSE 8211/udp
VOLUME /home/nonroot/PalServer/Pal/Saved

ENTRYPOINT ["./PalServer/Pal/Binaries/Linux/PalServer-Linux-Test", "Pal"]
CMD ["-useperfthreads", "-NoAsyncLoadingThread", "-UseMultithreadForDS"]
docker-compose.yml
version: '3.9'

services:
  palserver:
    build:
      context: .
      dockerfile: Dockerfile
    ports:
      - 8211:8211/udp
    volumes:
      - ./Saved:/home/nonroot/PalServer/Pal/Saved
  1. PalServer フォルダ内に Saved フォルダを作成する
mkdir Saved
  1. build & run
docker compose up -d

グレースフルシャットダウン対応Ver

  1. Saved/Config/LinuxServer/PalWorldSettings.ini で RCON を有効にする (AdminPassword="hogePassword",RCONEnabled=True,RCONPort=25575)

ref: https://tech.palworldgame.com/optimize-game-balance

PalWorldSettings.ini
[/Script/Pal.PalGameWorldSettings]
OptionSettings=(Difficulty=None,DayTimeSpeedRate=1.000000,NightTimeSpeedRate=1.000000,ExpRate=1.000000,PalCaptureRate=1.000000,PalSpawnNumRate=1.000000,PalDamageRateAttack=1.000000,PalDamageRateDefense=1.000000,PlayerDamageRateAttack=1.000000,PlayerDamageRateDefense=1.000000,PlayerStomachDecreaceRate=1.000000,PlayerStaminaDecreaceRate=1.000000,PlayerAutoHPRegeneRate=1.000000,PlayerAutoHpRegeneRateInSleep=1.000000,PalStomachDecreaceRate=1.000000,PalStaminaDecreaceRate=1.000000,PalAutoHPRegeneRate=1.000000,PalAutoHpRegeneRateInSleep=1.000000,BuildObjectDamageRate=1.000000,BuildObjectDeteriorationDamageRate=1.000000,CollectionDropRate=1.000000,CollectionObjectHpRate=1.000000,CollectionObjectRespawnSpeedRate=1.000000,EnemyDropItemRate=1.000000,DeathPenalty=All,bEnablePlayerToPlayerDamage=False,bEnableFriendlyFire=False,bEnableInvaderEnemy=True,bActiveUNKO=False,bEnableAimAssistPad=True,bEnableAimAssistKeyboard=False,DropItemMaxNum=3000,DropItemMaxNum_UNKO=100,BaseCampMaxNum=128,BaseCampWorkerMaxNum=15,DropItemAliveMaxHours=1.000000,bAutoResetGuildNoOnlinePlayers=False,AutoResetGuildTimeNoOnlinePlayers=72.000000,GuildPlayerMaxNum=20,PalEggDefaultHatchingTime=72.000000,WorkSpeedRate=1.000000,bIsMultiplay=False,bIsPvP=False,bCanPickupOtherGuildDeathPenaltyDrop=False,bEnableNonLoginPenalty=True,bEnableFastTravel=True,bIsStartLocationSelectByMap=True,bExistPlayerAfterLogout=False,bEnableDefenseOtherGuildPlayer=False,CoopPlayerMaxNum=4,ServerPlayerMaxNum=32,ServerName="Default Palworld Server",ServerDescription="",AdminPassword="hogePassword",ServerPassword="",PublicPort=8211,PublicIP="",RCONEnabled=True,RCONPort=25575,Region="",bUseAuth=True,BanListURL="https://api.palworldgame.com/api/banlist.txt")
  1. PalServer フォルダ内に ↓ の entrypoint.shrcon.yaml を作成する
entrypoint.sh
#!/busybox/sh

./Steam/steamapps/common/PalServer/Pal/Binaries/Linux/PalServer-Linux-Test Pal "$@" &
PID=$!

trap './rcon-cli/rcon "Shutdown ${SHUTDOWN_SECONDS} ${SHUTDOWN_MESSAGE}" && wait || kill $PID && wait' TERM

wait
rcon.yaml
default:
  address: "localhost:25575" # host:port, for example 127.0.0.1:16260
  password: "hogePassword"
  log: "rcon-default.log"
  type: "" # rcon, telnet, web.
  timeout: "10s"
  1. Dockerfiledocker-compose.yml を ↓ の様に変更する
Dockerfile
FROM steamcmd/steamcmd:debian-12 AS build
ARG RCON_VERSION=0.10.3

RUN steamcmd +login anonymous +app_update 2394010 validate +quit

ADD https://github.com/gorcon/rcon-cli/releases/download/v${RCON_VERSION}/rcon-${RCON_VERSION}-amd64_linux.tar.gz .
RUN tar -xzf rcon-${RCON_VERSION}-amd64_linux.tar.gz \
    && mv rcon-${RCON_VERSION}-amd64_linux rcon-cli

FROM gcr.io/distroless/cc-debian12:debug-nonroot AS base

COPY --from=build --chown=nonroot /root/.local/share/Steam/steamapps/common/PalServer/ PalServer/
COPY --from=build /root/.steam/sdk64/steamclient.so .steam/sdk64/
COPY --from=build /root/rcon-cli/ rcon-cli/

COPY ./entrypoint.sh .

EXPOSE 8211/udp 25575
VOLUME /home/nonroot/PalServer/Pal/Saved

ENTRYPOINT ["./entrypoint.sh"]
CMD ["-useperfthreads", "-NoAsyncLoadingThread", "-UseMultithreadForDS"]

HEALTHCHECK CMD ["./rcon-cli/rcon", "Info"]
docker-compose.yml
version: '3.9'

services:
  palserver:
    build:
      context: .
      dockerfile: Dockerfile
    ports:
      - 8211:8211/udp
      - 25575:25575
    volumes:
      - ./Saved:/home/nonroot/PalServer/Pal/Saved
      - ./rcon.yaml:/home/nonroot/rcon.yaml
    environment:
      - SHUTDOWN_SECONDS=60
      - SHUTDOWN_MESSAGE=The_server_will_shutdown_in_60_seconds.
    stop_grace_period: 1m30s
    restart: on-failure

ヘルスチェックも付けてるからあとは willfarrell/autoheal 使うなり Podman 使うなりいい感じによろ


https://tech.palworldgame.com/dedicated-server-guide
https://developer.valvesoftware.com/wiki/SteamCMD
https://github.com/gorcon/rcon-cli

Discussion