1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
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
|