41 lines
1.3 KiB
Text
41 lines
1.3 KiB
Text
--!strict
|
|
local process = require("@lune/process")
|
|
|
|
local common = require("../common")
|
|
local result = require("@pkg/result")
|
|
|
|
local function ssh_docker_replicator(dist_folder: string, remote_output: string): result.Identity<nil>
|
|
local split = string.split(remote_output, "->")
|
|
|
|
local remote_machine = split[1]
|
|
if not remote_machine then
|
|
return result(false, "Couldn't get the remote machine to ssh into.")
|
|
end
|
|
|
|
local docker_path = split[2]
|
|
if not docker_path then
|
|
return result(false, "Couldn't get the docker container path for the remote machine.")
|
|
end
|
|
|
|
local ssh_copy_result = process.spawn(
|
|
"scp",
|
|
{ "-r", "-O", dist_folder, `{remote_machine}:/tmp/cssharp-replicate` },
|
|
{ stdio = "forward" }
|
|
)
|
|
if not ssh_copy_result.ok then
|
|
return result(false, `Failed to copy files to the remote machine:\n{ssh_copy_result.stderr}`)
|
|
end
|
|
|
|
local docker_copy_result = process.spawn(
|
|
"ssh",
|
|
{ "-t", remote_machine, `"docker cp -r /tmp/cssharp-replicate {docker_path}"` },
|
|
{ stdio = "forward" }
|
|
)
|
|
if not docker_copy_result.ok then
|
|
return result(false, `Failed to copy files via docker on the remote machine:\n{docker_copy_result.stderr}`)
|
|
end
|
|
|
|
return result(true, nil)
|
|
end
|
|
|
|
return ssh_docker_replicator :: common.Replicator
|