_     _
                       _ __ | |__ | | ___   __ _
                      | '_ \| '_ \| |/ _ \ / _` |
                      | |_) | | | | | (_) | (_| |
                      | .__/|_| |_|_|\___/ \__, |
                      |_|    ...2017-02-08 |___/

Factorio server in Docker
There's really no reason to pull an image to run Factorio inside docker.
The headless Factorio server behaves nicely inside docker (though it does emit
an error message about not being able to open stdin, this is totally okay), it
also reacts correctly to SIGTERM, so when you docker stop the container, the
Factorio server shuts down gracefully.
The official Debian Jessie image is just fine (tm).

Here's what you need to do, in your bash:

# Acquire the latest version (may change)
wget https://www.factorio.com/get-download/0.14.22/headless/linux64  -O f.tgz
# Extract
tar xf f.tgz && rm f.tgz

# Configure (see wiki for info on configuration settings)
pushd factorio
mkdir saves
cp data/server-settings.example.json settings.json
vim settings.json
popd

# Generate map
docker run --rm -ti -v `pwd`/factorio:/factorio \
--workdir /factorio/ --entrypoint ./bin/x64/factorio \
debian:jessie --create ./saves/the-world.zip

# Start the server
docker run -d -p 34197:34197/udp --name factorio -v `pwd`/factorio:/factorio \
--workdir /factorio/ --entrypoint ./bin/x64/factorio \
debian:jessie --start-server-load-latest --server-settings ./settings.json


Internet stuff
You need to route UDP port 34197 to your dockerhosts IP.

Security
I have a user for file-system level isolation between docker processes and other
users, which I've called "dockerfs" and given the uid/gid of 9000.
If you want to do something similar, the following steps can be taken.
Assign user/group ownership to your isolation user on the factorio directory.
Add --user 9000:9000 to run commands, or whatever your isolation users id is.

Free bonus
Knowing how to start the server is only half the fun, you also want to control
and maintain it, you should also know how to start/stop and remove it.
Here are some additional commands you can run in bash:

# Observe logs (stop looking with Ctrl+c)
docker logs -f factorio

# Stop the server (if you need to do that..)
docker stop factorio

# Start a previously stopped serveer
docker start factorio

# Remove stopped server (not removing datafiles as they are stored on the host)
docker rm factorio


Other stuff
Wrote a bit more on the phlog, so now headlines are anchored. Anchors are a too-
little used feature of HTML and URLs, but they're awesome, they allow you to not
only link to a page, but to a specific PLACE in a page. It works by allowing you
to right-click on any headline and choose "copy link location", now you can link
directly to that section of a phlog entry. Very useful indeed. I actually wanted
to start looking into fuzzy searching, but I didn't get around to it, and it's a
bit too late now at 00:19.

It's 00:49
I wrote a search function, couldn't stop myself, it's not very good, but it kind
of works okay for some things.. Basically the phlog can be queried by visiting
/find with a query string. For example you can (fuzzy) search for Factorio by
visiting: http://dusted.dk/pages/phlog/find?Factorio granted, it's not that
good at all, but it'll be fine enough for me to be able to find what I need.

                                                                          -OUT.