aboutsummaryrefslogtreecommitdiff
path: root/scripts/docker.lua
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2026-03-16 10:56:11 +0100
committerGitHub Enterprise <[email protected]>2026-03-16 10:56:11 +0100
commit8c3ba4e8c522d119df3cb48966e36c0eaa80aeb9 (patch)
treecf51b07e097904044b4bf65bc3fe0ad14134074f /scripts/docker.lua
parentMerge branch 'sb/no-network' of https://github.ol.epicgames.net/ue-foundation... (diff)
parentEnable cross compilation of Windows targets on Linux (#839) (diff)
downloadzen-sb/no-network.tar.xz
zen-sb/no-network.zip
Merge branch 'main' into sb/no-networksb/no-network
Diffstat (limited to 'scripts/docker.lua')
-rw-r--r--scripts/docker.lua88
1 files changed, 88 insertions, 0 deletions
diff --git a/scripts/docker.lua b/scripts/docker.lua
new file mode 100644
index 000000000..f66f8db86
--- /dev/null
+++ b/scripts/docker.lua
@@ -0,0 +1,88 @@
+-- Copyright Epic Games, Inc. All Rights Reserved.
+
+import("core.base.option")
+
+--------------------------------------------------------------------------------
+local function _get_version()
+ local version_file = path.join(os.projectdir(), "VERSION.txt")
+ local version = io.readfile(version_file)
+ if version then
+ version = version:trim()
+ end
+ if not version or version == "" then
+ raise("Failed to read version from VERSION.txt")
+ end
+ return version
+end
+
+--------------------------------------------------------------------------------
+function main()
+ local registry = option.get("registry")
+ local tag = option.get("tag")
+ local push = option.get("push")
+ local no_wine = option.get("no-wine")
+ local win_binary = option.get("win-binary")
+
+ if not tag then
+ tag = _get_version()
+ end
+
+ local image_name = no_wine and "zenserver-compute-linux" or "zenserver-compute"
+ if registry then
+ image_name = registry .. "/" .. image_name
+ end
+
+ local full_tag = image_name .. ":" .. tag
+
+ -- Verify the zenserver binary exists
+ local binary_path = path.join(os.projectdir(), "build/linux/x86_64/release/zenserver")
+ if not os.isfile(binary_path) then
+ raise("zenserver binary not found at %s\nBuild it first with: xmake config -y -m release -a x64 && xmake build -y zenserver", binary_path)
+ end
+
+ -- Stage Windows binary if provided
+ local win_staging_dir = nil
+ if win_binary then
+ if not os.isfile(win_binary) then
+ raise("Windows binary not found at %s", win_binary)
+ end
+ win_staging_dir = path.join(os.projectdir(), "build/win-binary-staging")
+ os.mkdir(win_staging_dir)
+ os.cp(win_binary, path.join(win_staging_dir, "zenserver.exe"))
+ print("-- Including Windows binary: %s", win_binary)
+ end
+
+ -- Build the Docker image
+ local dockerfile = path.join(os.projectdir(), "docker/Dockerfile")
+ print("-- Building Docker image: %s", full_tag)
+ local args = {"build", "-t", full_tag, "-f", dockerfile}
+ if no_wine then
+ table.insert(args, "--build-arg")
+ table.insert(args, "INSTALL_WINE=false")
+ end
+ if win_staging_dir then
+ table.insert(args, "--build-arg")
+ table.insert(args, "WIN_BINARY_DIR=build/win-binary-staging")
+ end
+ table.insert(args, os.projectdir())
+ local ret = os.execv("docker", args)
+ if ret > 0 then
+ raise("Docker build failed")
+ end
+
+ -- Clean up staging directory
+ if win_staging_dir then
+ os.rmdir(win_staging_dir)
+ end
+
+ print("-- Built image: %s", full_tag)
+
+ if push then
+ print("-- Pushing image: %s", full_tag)
+ ret = os.execv("docker", {"push", full_tag})
+ if ret > 0 then
+ raise("Docker push failed")
+ end
+ print("-- Pushed image: %s", full_tag)
+ end
+end