diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..4f68ff19 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,11 @@ +FROM node:latest +RUN apt-get update && apt install git -y && git clone https://github.com/Danielv123/factorioClusterio.git && cd factorioClusterio && npm install && curl -o factorio.tar.gz -L https://www.factorio.com/get-download/latest/headless/linux64 && tar -xvzf factorio.tar.gz + +LABEL maintainer "danielv@live.no" + +EXPOSE 8080 34167 + +VOLUME /factorioClusterio/instances + +WORKDIR factorioClusterio +CMD node $MODE\.js start $INSTANCE \ No newline at end of file diff --git a/README.md b/README.md index f78d3a4c..1f292842 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -#factorioClusterio +# factorioClusterio If you want to connect to a clusterio cluster, please reffer to the [client](https://github.com/Danielv123/factorioClusterioClient) @@ -18,7 +18,7 @@ Connection diagram: There can be any number of clients connected to each slave, and any sumber of slaves connected to a master but there can only be one master server. -#Ubuntu setup +# Ubuntu setup NodeJS does not support EOL ubuntu releases. Make sure you are on the most recent LTS release or newer. @@ -48,7 +48,19 @@ To launch an instance with pm2 use `nano config.json` to change settings. -#Windows setup +**Ubuntu with Docker** + +Clusterio has limited support for using docker. + + sudo docker build -t clusterio --no-cache --force-rm factorioClusterio + + sudo docker run --name master -e MODE=master -p 1234:8080 -d -it --restart=unless-stopped danielvestol/clusterio + + sudo docker run --name slave -e MODE=client -e INSTANCE=world1 -v /srv/clusterio/instances:/factorioClusterio/instances -p 1235:34167 -it --restart=unless-stopped danielvestol/clusterio + +The -v flag is used to specify the instance directory. Your instances (save files etc) will be stored there. + +# Windows setup Clusterio is built up of multiple parts. Here is a quick guide: @@ -86,7 +98,7 @@ reboot when you are done, then proceed to the next steps. *reboots matter* 3. Type `node client.js start [instancename]` to create a new instance. -To connect to a master server running on a remote machine, open config.json with your favourite text editor (notepad++). You can also set it up to use the official server browser server. +To connect to a master server running on a remote machine, open config.json with your favourite text editor (notepad++). You can also set it up to use the official server browser. Change masterIP to something like 31.152.123.14 (provided by master server owner) @@ -96,7 +108,7 @@ Repeat step 3 for more servers on one machine. You should be able to find its po **GameClient** -Alternative experimental client that may be broken: [clusterioClient](https://github.com/Danielv123/factorioClusterioClient) +Fancy game client that does the following steps automatically: [clusterioClient](https://github.com/Danielv123/factorioClusterioClient) 1. Download the same version of the mod as the slave is running from [the mod portal](https://mods.factorio.com/mods/Danielv123/clusterio) or [github](https://github.com/Danielv123/factorioClusterioMod diff --git a/client.js b/client.js index 48035ff4..7e4c8dd3 100644 --- a/client.js +++ b/client.js @@ -354,7 +354,7 @@ function instanceManagement() { if(fs.existsSync(instancedirectory + "/script-output/tempfile.txt")) { var data = fs.readFileSync(instancedirectory + "/script-output/tempfile.txt", "utf8").split("\n"); // delete when we are done - fs.unlink(instancedirectory + "/script-output/tempfile.txt"); + fs.unlink(instancedirectory + "/script-output/tempfile.txt", function(){}); } // if we actually got anything from the file, proceed to categorize it if (data && data[0]) {