mirror of
				https://github.com/factoriotools/factorio-docker.git
				synced 2025-10-31 00:48:07 +01:00 
			
		
		
		
	Added creation and symlinking of scenarios directory, creation and symlinking of an entrypoints directory for custom entrypoints, and two examples of using entrypoints with scenarios
This commit is contained in:
		| @@ -23,6 +23,8 @@ RUN mkdir -p /opt /factorio && \ | ||||
|     rm /tmp/factorio_headless_x64_$VERSION.tar.xz && \ | ||||
|     ln -s /factorio/saves /opt/factorio/saves && \ | ||||
|     ln -s /factorio/mods /opt/factorio/mods && \ | ||||
|     ln -s /factorio/scenarios /opt/factorio/scenarios && \ | ||||
|     ln -s /factorio/entrypoints /opt/factorio/entrypoints && \ | ||||
|     apk del .build-deps && \ | ||||
|     addgroup -g $PGID -S $GROUP && \ | ||||
|     adduser -u $PUID -G $USER -s /bin/sh -SDH $GROUP && \ | ||||
|   | ||||
| @@ -6,10 +6,18 @@ id | ||||
|  | ||||
| SAVES=/factorio/saves | ||||
| CONFIG=/factorio/config | ||||
| MODS=/factorio/mods | ||||
| SCENARIOS=/factorio/scenarios | ||||
| ENTRYPOINTS=/factorio/entrypoints | ||||
|  | ||||
| mkdir -p $SAVES | ||||
| mkdir -p /factorio/mods | ||||
| mkdir -p $CONFIG | ||||
| mkdir -p $MODS | ||||
| mkdir -p $SCENARIOS | ||||
| mkdir -p $ENTRYPOINTS | ||||
|  | ||||
| #symbolic link the default entrypoint to the entrypoints directory so it can be inspected and copied to new entrypoints | ||||
| ln -s /docker-entrypoint.sh $ENTRYPOINTS/docker-entrypoint.sh | ||||
|  | ||||
| #chown -R factorio /factorio | ||||
|  | ||||
|   | ||||
							
								
								
									
										49
									
								
								0.16/scenario.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										49
									
								
								0.16/scenario.sh
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,49 @@ | ||||
| #!/bin/sh -x | ||||
| if [ -z "$1" ] | ||||
|   then | ||||
|     echo "No argument supplied" | ||||
| fi | ||||
| SCENARIO=$1 | ||||
|  | ||||
| set -e | ||||
|  | ||||
| id | ||||
|  | ||||
| SAVES=/factorio/saves | ||||
| CONFIG=/factorio/config | ||||
| MODS=/factorio/mods | ||||
| SCENARIOS=/factorio/scenarios | ||||
|  | ||||
| mkdir -p $SAVES | ||||
| mkdir -p $CONFIG | ||||
| mkdir -p $MODS | ||||
| mkdir -p $SCENARIOS | ||||
|  | ||||
| #chown -R factorio /factorio | ||||
|  | ||||
| if [ ! -f $CONFIG/rconpw ]; then | ||||
|   echo $(pwgen 15 1) > $CONFIG/rconpw | ||||
| fi | ||||
|  | ||||
| if [ ! -f $CONFIG/server-settings.json ]; then | ||||
|   cp /opt/factorio/data/server-settings.example.json $CONFIG/server-settings.json | ||||
| fi | ||||
|  | ||||
| if [ ! -f $CONFIG/map-gen-settings.json ]; then | ||||
|   cp /opt/factorio/data/map-gen-settings.example.json $CONFIG/map-gen-settings.json | ||||
| fi | ||||
|  | ||||
| if [ ! -f $CONFIG/map-settings.json ]; then | ||||
|   cp /opt/factorio/data/map-settings.example.json $CONFIG/map-settings.json | ||||
| fi | ||||
|  | ||||
|  | ||||
| exec /opt/factorio/bin/x64/factorio \ | ||||
|   --port $PORT \ | ||||
|   --start-server-load-scenario $SCENARIO \ | ||||
|   --server-settings $CONFIG/server-settings.json \ | ||||
|   --server-whitelist $CONFIG/server-whitelist.json \ | ||||
|   --server-banlist $CONFIG/server-banlist.json \ | ||||
|   --rcon-port $RCON_PORT \ | ||||
|   --rcon-password "$(cat $CONFIG/rconpw)" \ | ||||
|   --server-id /factorio/config/server-id.json | ||||
							
								
								
									
										36
									
								
								0.16/scenario2map.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										36
									
								
								0.16/scenario2map.sh
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,36 @@ | ||||
| #!/bin/sh -x | ||||
| if [ -z "$1" ] | ||||
|   then | ||||
|     echo "No argument supplied" | ||||
| fi | ||||
|  | ||||
| set -e | ||||
|  | ||||
| id | ||||
|  | ||||
| SAVES=/factorio/saves | ||||
| CONFIG=/factorio/config | ||||
| MODS=/factorio/mods | ||||
| SCENARIOS=/factorio/scenarios | ||||
|  | ||||
| mkdir -p $SAVES | ||||
| mkdir -p $CONFIG | ||||
| mkdir -p $MODS | ||||
| mkdir -p $SCENARIOS | ||||
|  | ||||
| #chown -R factorio /factorio | ||||
|  | ||||
| if [ ! -f $CONFIG/server-settings.json ]; then | ||||
|   cp /opt/factorio/data/server-settings.example.json $CONFIG/server-settings.json | ||||
| fi | ||||
|  | ||||
| if [ ! -f $CONFIG/map-gen-settings.json ]; then | ||||
|   cp /opt/factorio/data/map-gen-settings.example.json $CONFIG/map-gen-settings.json | ||||
| fi | ||||
|  | ||||
| if [ ! -f $CONFIG/map-settings.json ]; then | ||||
|   cp /opt/factorio/data/map-settings.example.json $CONFIG/map-settings.json | ||||
| fi | ||||
|  | ||||
| exec /opt/factorio/bin/x64/factorio \ | ||||
|   --scenario2map $1 | ||||
							
								
								
									
										32
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										32
									
								
								README.md
									
									
									
									
									
								
							| @@ -113,6 +113,38 @@ To generate a new map stop the server, delete all of the saves and restart the s | ||||
| Copy mods into the mods folder and restart the server. | ||||
|  | ||||
|  | ||||
| ## Scenarios | ||||
|  | ||||
| If you want to launch a scenario from a clean start (not from a saved map) you'll need to start the docker image from an alternate entrypoint. To do this, use the example entrypoint file stored in the /factorio/entrypoints directory in the volume, and launch the image with the following syntax. Note that this is the normal syntax with the addition of the --entrypoint setting AND the additional argument at the end, which is the name of the Scenario in the Scenarios folder. | ||||
|  | ||||
| ``` | ||||
| docker run -d \ | ||||
|   -p 34197:34197/udp \ | ||||
|   -p 27015:27015/tcp \ | ||||
|   -v /opt/factorio:/factorio \ | ||||
|   --name factorio \ | ||||
|   --restart=always  \ | ||||
|   --entrypoint "/factorio/entrypoints/scenario.sh" \ | ||||
|   dtandersen/factorio \ | ||||
|   MyScenarioName | ||||
| ``` | ||||
|  | ||||
| ## Converting Scenarios to Regular Maps | ||||
|  | ||||
| If you would like to export your scenario to a saved map, you can use the example entrypoint similar to the Scenario usag above. Factorio will run once, converting the Scenario to a saved Map in your saves directory. A restart of the docker image using the standard options will then load that map, just as if the scenario were just started by the Scenarios example noted above.  | ||||
|  | ||||
| ``` | ||||
| docker run -d \ | ||||
|   -p 34197:34197/udp \ | ||||
|   -p 27015:27015/tcp \ | ||||
|   -v /opt/factorio:/factorio \ | ||||
|   --name factorio \ | ||||
|   --restart=always  \ | ||||
|   --entrypoint "/factorio/entrypoints/scenario2map.sh" \ | ||||
|   dtandersen/factorio | ||||
|   MyScenarioName | ||||
| ``` | ||||
|  | ||||
| ## RCON | ||||
|  | ||||
| Set the RCON password in the `rconpw` file. A random password is generated if `rconpw` doesn't exist. | ||||
|   | ||||
		Reference in New Issue
	
	Block a user