factoriotools / factorio-docker

Factorio headless server in a Docker container
https://hub.docker.com/r/factoriotools/factorio/
MIT License
918 stars 218 forks source link

Expose config file locations as env vars #356

Closed SQLJames closed 2 years ago

SQLJames commented 3 years ago

In the factorio-server-charts, to allow us to specify the config values we are using configmaps, which creates the json file and mounts it to the proper location, however they are Read only files. This poses an issue when the server-id.json is needed to create a public server because it needs rw operations. I am currently looking into creating a sidecar to copy the files into the proper directory so we can properly rw to the directory.

But in my digging to resolve this issue, this solution did come up as a potential fix, so I had to ask if your project would be open to accepting a pull request that allows users to specify the location of config files as an ENV variable.

For example, in the docker-entrypoint.sh file, we could check to see if the ENV is specified and if so, we would use that value instead of the location put in the flag arg list. For example:

#-z string True if the string is null
if [ -z "${FACTORIO_SERVER_ID_LOCATION}" ]; then
    FACTORIO_SERVER_ID_LOCATION="/factorio/config/server-id.json"
fi

FLAGS=(\
  --port "$PORT" \
  --server-settings "$CONFIG/server-settings.json" \
  --server-banlist "$CONFIG/server-banlist.json" \
  --rcon-port "$RCON_PORT" \
  --server-whitelist "$CONFIG/server-whitelist.json" \
  --use-server-whitelist \
  --server-adminlist "$CONFIG/server-adminlist.json" \
  --rcon-password "$(cat "$CONFIG/rconpw")" \
  --server-id $FACTORIO_SERVER_ID_LOCATION \
)
SuperSandro2000 commented 3 years ago

Would be fine for me.

SQLJames commented 2 years ago

solved this with https://github.com/SQLJames/factorio-server-charts/pull/13