Add caching for Gitea Actions, improve performance

This commit is contained in:
2026-08-08 10:11:28 -06:00
parent 63d6b1eb9c
commit 71a27eb3ca
6 changed files with 58 additions and 4 deletions
+27 -2
View File
@@ -35,14 +35,39 @@ directory "#{working_directory}/runners" do
mode "0700"
end
runners.each do |runner|
execute "create_gitea_actions_network" do
command "docker network create --subnet 172.20.0.0/16 gitea-actions"
not_if "docker network inspect gitea-actions"
end
runners.each_with_index do |runner, index|
runner_name = "gitea-runner-#{runner["org"]}"
runner_dir = "#{working_directory}/runners/#{runner["org"]}"
cache_port = node["gitea"]["runner"]["cache_base_port"] + index
directory runner_dir do
mode "0700"
end
runner_config = node["gitea"]["runner"]["config"].to_hash
runner_config["cache"] = runner_config["cache"].merge("port" => cache_port)
firewall_rule "runner_cache_#{runner["org"]}" do
command :allow
port cache_port
protocol :tcp
source "172.20.0.0/16"
end
template "#{runner_dir}/config.yaml" do
source "runner.config.yaml.erb"
mode "0640"
owner "root"
group "root"
variables(config: runner_config)
notifies :restart, "service[#{runner_name}]", :delayed
end
bash "register_#{runner["org"]}_runner" do
cwd runner_dir
code <<-EOF
@@ -67,7 +92,7 @@ gitea_runner register \
Type: "simple",
WorkingDirectory: runner_dir,
Environment: "HOME=/root",
ExecStart: "/usr/local/bin/gitea_runner daemon",
ExecStart: "/usr/local/bin/gitea_runner daemon --config #{runner_dir}/config.yaml",
ExecStartPre: "/bin/sleep 3", # Wait for Gitea's API to be up when restarting at the same time
Restart: "always",
},