forked from hswaw/hscloud
third_party/factorio: init
We turn the existing experimental BUILD file into a nicely abstracted starlark rule generator, for generating both external repositories and container build rules from a single source of truth. We also add 0.18.22 (which we already pushed via :push_latest). Change-Id: I521d6e5cb9447eaf6f237671b7ef07d621cd9c77master
parent
6a0b75bd84
commit
480505768d
47
WORKSPACE
47
WORKSPACE
|
@ -133,50 +133,9 @@ container_pull(
|
||||||
digest = "sha256:8f58236129e6547d92502a2e9d8f40129f45f15007beaeafb59fed4faffddb3e",
|
digest = "sha256:8f58236129e6547d92502a2e9d8f40129f45f15007beaeafb59fed4faffddb3e",
|
||||||
)
|
)
|
||||||
|
|
||||||
# HTTP stuff from the Internet
|
# third_party/factorio
|
||||||
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_file")
|
load("//third_party/factorio:factorio.bzl", "factorio_repositories")
|
||||||
|
factorio_repositories()
|
||||||
http_file(
|
|
||||||
name = "factorio-headless-0.16.51",
|
|
||||||
urls = ["https://factorio.com/get-download/0.16.51/headless/linux64"],
|
|
||||||
sha256 = "6cb09f5ac87f16f8d5b43cef26c0ae26cc46a57a0382e253dfda032dc5bb367f",
|
|
||||||
downloaded_file_path = "factorio.tar.xz",
|
|
||||||
)
|
|
||||||
|
|
||||||
http_file(
|
|
||||||
name = "factorio-headless-0.17.41",
|
|
||||||
urls = ["https://factorio.com/get-download/0.17.41/headless/linux64"],
|
|
||||||
sha256 = "bf2d16b23c3bbd97e41889d3e27670b6d958fa3d50f0befb41d234f735e8e6d1",
|
|
||||||
downloaded_file_path = "factorio.tar.xz",
|
|
||||||
)
|
|
||||||
|
|
||||||
http_file(
|
|
||||||
name = "factorio-headless-0.17.52",
|
|
||||||
urls = ["https://factorio.com/get-download/0.17.52/headless/linux64"],
|
|
||||||
sha256 = "24458a4e16875b0b63677b7e7a068ce2e5b298c110381d17c6f596fd1406db0e",
|
|
||||||
downloaded_file_path = "factorio.tar.xz",
|
|
||||||
)
|
|
||||||
|
|
||||||
http_file(
|
|
||||||
name = "factorio-headless-0.17.79",
|
|
||||||
urls = ["https://factorio.com/get-download/0.17.79/headless/linux64"],
|
|
||||||
sha256 = "9ace12fa986df028dc1851bf4de2cb038044d743e98823bc1c48ba21aa4d23df",
|
|
||||||
downloaded_file_path = "factorio.tar.xz",
|
|
||||||
)
|
|
||||||
|
|
||||||
http_file(
|
|
||||||
name = "factorio-headless-0.18.12",
|
|
||||||
urls = ["https://factorio.com/get-download/0.18.12/headless/linux64"],
|
|
||||||
sha256 = "e0c6a46d66cfc02cba294a5fd34265e7e7a5168b8c8a7b16ad8dbac31470ed33",
|
|
||||||
downloaded_file_path = "factorio.tar.xz",
|
|
||||||
)
|
|
||||||
|
|
||||||
http_file(
|
|
||||||
name = "factorio-headless-0.18.17",
|
|
||||||
urls = ["https://factorio.com/get-download/0.18.17/headless/linux64"],
|
|
||||||
sha256 = "42adce9fddde393023afb0aae19dd030a32ca0810191c0e7b9b7c55556e9bbce",
|
|
||||||
downloaded_file_path = "factorio.tar.xz",
|
|
||||||
)
|
|
||||||
|
|
||||||
# Go rules
|
# Go rules
|
||||||
|
|
||||||
|
|
|
@ -1,65 +0,0 @@
|
||||||
load("@io_bazel_rules_docker//container:container.bzl", "container_image")
|
|
||||||
load("@io_bazel_rules_docker//container:container.bzl", "container_push")
|
|
||||||
|
|
||||||
container_image(
|
|
||||||
name="0.16.51-1",
|
|
||||||
base="@prodimage-bionic//image",
|
|
||||||
tars = ["@factorio-headless-0.16.51//file"],
|
|
||||||
files = [":entrypoint.sh"],
|
|
||||||
directory = "/",
|
|
||||||
entrypoint = ["/entrypoint.sh"],
|
|
||||||
)
|
|
||||||
|
|
||||||
container_image(
|
|
||||||
name="0.17.41-1",
|
|
||||||
base="@prodimage-bionic//image",
|
|
||||||
tars = ["@factorio-headless-0.17.41//file"],
|
|
||||||
files = [":entrypoint.sh"],
|
|
||||||
directory = "/",
|
|
||||||
entrypoint = ["/entrypoint.sh"],
|
|
||||||
)
|
|
||||||
|
|
||||||
container_image(
|
|
||||||
name="0.17.52-1",
|
|
||||||
base="@prodimage-bionic//image",
|
|
||||||
tars = ["@factorio-headless-0.17.52//file"],
|
|
||||||
files = [":entrypoint.sh"],
|
|
||||||
directory = "/",
|
|
||||||
entrypoint = ["/entrypoint.sh"],
|
|
||||||
)
|
|
||||||
|
|
||||||
container_image(
|
|
||||||
name="0.17.79-1",
|
|
||||||
base="@prodimage-bionic//image",
|
|
||||||
tars = ["@factorio-headless-0.17.79//file"],
|
|
||||||
files = [":entrypoint.sh"],
|
|
||||||
directory = "/",
|
|
||||||
entrypoint = ["/entrypoint.sh"],
|
|
||||||
)
|
|
||||||
|
|
||||||
container_image(
|
|
||||||
name="0.18.12-2",
|
|
||||||
base="@prodimage-bionic//image",
|
|
||||||
tars = ["@factorio-headless-0.18.12//file"],
|
|
||||||
files = [":entrypoint.sh"],
|
|
||||||
directory = "/",
|
|
||||||
entrypoint = ["/entrypoint.sh"],
|
|
||||||
)
|
|
||||||
|
|
||||||
container_image(
|
|
||||||
name="0.18.17-1",
|
|
||||||
base="@prodimage-bionic//image",
|
|
||||||
tars = ["@factorio-headless-0.18.17//file"],
|
|
||||||
files = [":entrypoint.sh"],
|
|
||||||
directory = "/",
|
|
||||||
entrypoint = ["/entrypoint.sh"],
|
|
||||||
)
|
|
||||||
|
|
||||||
container_push(
|
|
||||||
name = "push_latest",
|
|
||||||
image = ":0.18.17-1",
|
|
||||||
format = "Docker",
|
|
||||||
registry = "registry.k0.hswaw.net",
|
|
||||||
repository = "app/factorio",
|
|
||||||
tag = "0.18.17-1",
|
|
||||||
)
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
load("//third_party/factorio:factorio.bzl", "factorio_images")
|
||||||
|
|
||||||
|
factorio_images()
|
|
@ -0,0 +1,6 @@
|
||||||
|
Factorio
|
||||||
|
========
|
||||||
|
|
||||||
|
We allow importing [Factorio](https://factorio.com/) server binaries into hscloud. A machinery is provided that builds Docker images for a given version of factorio and pushes them to `registry.k0.hswaw.net/app/factorio:${version}-${revision}`. Available versions are defined in [factorio.bzl](factorio.bzl).
|
||||||
|
|
||||||
|
Production deployments of Factorio are still experimental, see [personal/q3k/factorio](/personal/q3k/factorio).
|
|
@ -0,0 +1,81 @@
|
||||||
|
"""
|
||||||
|
Automatically download, package, containerize and push Factorio server images.
|
||||||
|
|
||||||
|
For each version defined, the following will be declared:
|
||||||
|
- @factorio-headless-${version}: a repository containing the factorio server tarball
|
||||||
|
- //third_party/factorio:${version}-1: a container_image rule to build a docker container running a factorio server
|
||||||
|
- //third_party/factorio:push_${version}-1: a container_push rule to push that container image to registry.k0.hswaw.net/app/factorio:${version}-1
|
||||||
|
|
||||||
|
In addition, a //third_party/factorio:push_latest rule will also be created for the highest versioned server version. This is for convenience.
|
||||||
|
|
||||||
|
To add a new version of Factorio, just update the _versions map with the new version number and the sha256 sum of its tarball.
|
||||||
|
"""
|
||||||
|
|
||||||
|
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_file")
|
||||||
|
load("@io_bazel_rules_docker//container:container.bzl", "container_image", "container_push")
|
||||||
|
|
||||||
|
# version -> sha256 of server tarball
|
||||||
|
_versions = {
|
||||||
|
"0.16.51": "6cb09f5ac87f16f8d5b43cef26c0ae26cc46a57a0382e253dfda032dc5bb367f",
|
||||||
|
"0.17.41": "bf2d16b23c3bbd97e41889d3e27670b6d958fa3d50f0befb41d234f735e8e6d1",
|
||||||
|
"0.17.52": "24458a4e16875b0b63677b7e7a068ce2e5b298c110381d17c6f596fd1406db0e",
|
||||||
|
"0.17.79": "9ace12fa986df028dc1851bf4de2cb038044d743e98823bc1c48ba21aa4d23df",
|
||||||
|
"0.18.12": "e0c6a46d66cfc02cba294a5fd34265e7e7a5168b8c8a7b16ad8dbac31470ed33",
|
||||||
|
"0.18.17": "42adce9fddde393023afb0aae19dd030a32ca0810191c0e7b9b7c55556e9bbce",
|
||||||
|
"0.18.22": "d90e349b61182c1e48bd34797faedc2f9b5b4e349d218ef3d987ae9d90762f7f",
|
||||||
|
}
|
||||||
|
|
||||||
|
def factorio_repository(version, sha256):
|
||||||
|
http_file(
|
||||||
|
name = "factorio-headless-%s" % (version),
|
||||||
|
urls = [
|
||||||
|
"https://factorio.com/get-download/%s/headless/linux64" % (version),
|
||||||
|
],
|
||||||
|
sha256 = sha256,
|
||||||
|
downloaded_file_path = "factorio.tar.xz",
|
||||||
|
)
|
||||||
|
|
||||||
|
def factorio_repositories():
|
||||||
|
for v, sha256 in _versions.items():
|
||||||
|
factorio_repository(v, sha256)
|
||||||
|
|
||||||
|
def factorio_image(version, revision):
|
||||||
|
image_name = "%s-%d" % (version, revision)
|
||||||
|
container_image(
|
||||||
|
name = image_name,
|
||||||
|
base = "@prodimage-bionic//image",
|
||||||
|
tars = ["@factorio-headless-%s//file" % (version)],
|
||||||
|
files = [":entrypoint.sh"],
|
||||||
|
directory = "/",
|
||||||
|
entrypoint = ["/entrypoint.sh"],
|
||||||
|
)
|
||||||
|
container_push(
|
||||||
|
name = "push_%s-%d" % (version, revision),
|
||||||
|
image = ":%s" % (image_name),
|
||||||
|
format = "Docker",
|
||||||
|
registry = "registry.k0.hswaw.net",
|
||||||
|
repository = "app/factorio",
|
||||||
|
tag = "%s-%d" % (version, revision),
|
||||||
|
)
|
||||||
|
|
||||||
|
def _sort_by_version(v):
|
||||||
|
return [int(el) for el in v.split(".")]
|
||||||
|
|
||||||
|
def factorio_images():
|
||||||
|
revision_overrides = {
|
||||||
|
"0.18.12": 2,
|
||||||
|
}
|
||||||
|
for v in _versions.keys():
|
||||||
|
revision = revision_overrides.get(v, 1)
|
||||||
|
factorio_image(v, revision)
|
||||||
|
|
||||||
|
highest_version = sorted(_versions.keys(), key=_sort_by_version, reverse=True)[0]
|
||||||
|
revision = revision_overrides.get(highest_version, 1)
|
||||||
|
container_push(
|
||||||
|
name = "push_latest",
|
||||||
|
image = ":%s-%d" % (highest_version, revision),
|
||||||
|
format = "Docker",
|
||||||
|
registry = "registry.k0.hswaw.net",
|
||||||
|
repository = "app/factorio",
|
||||||
|
tag = "%s-%d" % (highest_version, revision),
|
||||||
|
)
|
Loading…
Reference in New Issue