goofball222 / factorio

Factorio headless server Docker container
Apache License 2.0
47 stars 14 forks source link

Experimental: FACTORIO_RCON_PORT="27015" is hard wired #5

Closed bplein closed 5 years ago

bplein commented 5 years ago

Reporting bugs/issues


    * Docker version:
`Docker version 18.09.0, build 4d60db4
`

    * Labels from container:

$ docker inspect goofball222/factorio:experimental "Labels": { "org.label-schema.build-date": "2019-03-07T16:35:30Z", "org.label-schema.license": "Apache-2.0", "org.label-schema.name": "Factorio Headless Server", "org.label-schema.schema-version": "1.0", "org.label-schema.url": "https://github.com/goofball222/factorio", "org.label-schema.vcs-ref": "93ac8bf", "org.label-schema.vcs-url": "https://github.com/goofball222/factorio.git", "org.label-schema.vendor": "The Goofball - goofball222@gmail.com", "org.label-schema.version": "0.17.8" }


    * Details on how to reproduce the trouble, if available:
I am trying to pass in custom ports for game and rcon. But rcon is hard-coded. See output from docker logs:

docker logs -f factorio4

2019-03-07T18:20:19.754 INFO - Script version 1.0.1 2019-03-07T18:20:19.757 INFO - Entrypoint running with UID 0 (root) 2019-03-07T18:20:19.760 INFO - GID/UID for factorio are unchanged: GID=999, UID=999 2019-03-07T18:20:19.765 INFO - RUN_CHOWN set to 'false' - Not running 'chown -R factorio:factorio /opt/factorio', assume permissions are right. 2019-03-07T18:20:19.766 INFO - Using existing RCON.pwd found in /opt/factorio/config 2019-03-07T18:20:19.769 INFO - RCON password is 'f95274fad5687330' 2019-03-07T18:20:19.772 INFO - Copied latest server-settings.example.json to /opt/factorio/config 2019-03-07T18:20:19.774 INFO - Copied latest map-gen-settings.example.json to /opt/factorio/config 2019-03-07T18:20:19.776 INFO - Using existing server-settings.json found in /opt/factorio/config 2019-03-07T18:20:19.778 INFO - Using existing map-gen-settings.json found in /opt/factorio/config 2019-03-07T18:20:19.780 INFO - Loading save.zip found in /opt/factorio/saves 2019-03-07T18:20:19.782 INFO - Use su-exec to drop priveleges and start Factorio Headless as GID=999, UID=999 2019-03-07T18:20:19.783 EXEC - su-exec factorio:factorio /opt/factorio/bin/x64/factorio "--port 34200 --rcon-port 27018 --rcon-password f95274fad5687330 --rcon-port 27015 --start-server-load-latest --server-settings /opt/factorio/config/server-settings.json 0.000 Error Main.cpp:487: Both --rcon-port and --rcon-password must be specified to enable RCON

goofball222 commented 5 years ago

I'll have to look at the container scripting, it's possible I left that hard-coded. I may have been assuming that it didn't need to be adjustable internally since it can just be remapped in the Docker, Compose, or other orchestration HOST:CONTAINER networking, assuming you're not using host networking mode. IE:

docker run --name factorio -d \
    -p 34197:34197/udp \
    -p 27018:27015 \
    goofball222/factorio

OR

version: '3'

services:
  factorio:
    image: goofball222/factorio
    container_name: factorio
    restart: unless-stopped
    ports:
      - 27018:27015
      - 34197:34197/udp
<snip>
bplein commented 5 years ago

But it can’t! The app is port aware and tells the pingpong host it’s port, even if it’s remapped to another poet by docker networking (or by a router). The external port and the port as it’s understood by the app must match.

At least that’s what I ran into back in the 16.x era.

Easiest change is to always set the game and rcon ports via the CLI, set them via environment variables that have defaults but can be override in the compose file

bplein commented 5 years ago

I may be wrong about the RCON port, it possibly could get redirected. I was thinking about the game port which cannot.

goofball222 commented 5 years ago

I can see where the "FACTIORIO_RCON_PORT" is getting overwritten in the startup script now that I look at it with that in mind, should be fairly simple to fix. I'll also go ahead and add a "FACTORIO_PORT" variable to allow that to be adjusted as well while I'm fixing the first one. I'll close this issue out once those changes are committed.

These changes will be applied to both the experimental and stable images, however the existing static images releases on Docker hub will not be updated.