app/factorio: build docker image
diff --git a/app/factorio/BUILD b/app/factorio/BUILD
new file mode 100644
index 0000000..dc5dfd5
--- /dev/null
+++ b/app/factorio/BUILD
@@ -0,0 +1,33 @@
+load("@io_bazel_rules_docker//container:container.bzl", "container_image")
+
+container_image(
+    name="latest",
+    base="@prodimage-bionic//image",
+	tars = ["@factorio-headless//file"],
+	files = [":entrypoint.sh"],
+	directory = "/",
+	entrypoint = ["/entrypoint.sh"],
+)
+
+# Totally broken right now because google/containerregistry doesn't handle
+# /usr/bin/env python == python3.
+#container_push(
+#    name = "push_latest",
+#    image = ":latest",
+#    format = "Docker",
+#    registry = "registry.k0.hswaw.net",
+#    repository = "app/factorio",
+#    tag = "latest",
+#)
+# So this is a replacement hack.
+genrule(
+	name = "push_latest",
+	srcs = [":latest"],
+	outs = ["version.sh"],
+	executable = True,
+	cmd = """
+		docker tag bazel/app/factorio:latest registry.k0.hswaw.net/app/factorio:latest
+        docker push registry.k0.hswaw.net/app/factorio:latest
+		echo -ne "#!/bin/sh\necho Tagged.\n" > $(OUTS)
+	""",
+)
diff --git a/app/factorio/entrypoint.sh b/app/factorio/entrypoint.sh
new file mode 100644
index 0000000..8077a1c
--- /dev/null
+++ b/app/factorio/entrypoint.sh
@@ -0,0 +1,18 @@
+#!/bin/bash
+
+echo "entrypoint.sh starting..."
+
+if [ ! -d /data ]; then
+    echo "/data is not mounted, exiting."
+    exit 1
+fi
+
+cd /data
+
+if [ ! -f /data/game.zip ]; then
+    echo "No save game, creating new..."
+    /factorio/bin/x64/factorio --create game
+fi
+
+echo "Running with args: $@"
+exec /factorio/bin/x64/factorio --start-server game "$@"
diff --git a/app/registry/prod.jsonnet b/app/registry/prod.jsonnet
index a7e1f5e..9b30d37 100644
--- a/app/registry/prod.jsonnet
+++ b/app/registry/prod.jsonnet
@@ -154,6 +154,11 @@
                         comment: "q3k and inf can mange 'vms' docker images",
                     },
                     {
+                        match: {account: "q3k", name: "app/factorio"},
+                        actions: ["*"],
+                        comment: "q3k can mange 'app/factorio' docker images",
+                    },
+                    {
                         match: {account: "/.+/", name: "${account}/*"},
                         actions: ["*"],
                         comment: "Logged in users have full access to images that are in their 'namespace'",