Copy edge E2E runner config in CI
This commit is contained in:
+44
-22
@@ -56,6 +56,7 @@ Options:
|
||||
--tail <lines> Log lines for the logs action. Default: 200
|
||||
--skip-compose-up Do not start the local Docker Compose stack before start.
|
||||
--skip-build Do not rebuild the test gateway image before start.
|
||||
--copy-config Copy generated config into the container instead of bind mounting it.
|
||||
`);
|
||||
}
|
||||
|
||||
@@ -150,6 +151,7 @@ export function parseArgs(argv = process.argv.slice(2)) {
|
||||
tail: "200",
|
||||
skipComposeUp: false,
|
||||
skipBuild: false,
|
||||
copyConfig: false,
|
||||
};
|
||||
|
||||
for (let index = 0; index < rest.length; index += 1) {
|
||||
@@ -204,6 +206,9 @@ export function parseArgs(argv = process.argv.slice(2)) {
|
||||
case "--skip-build":
|
||||
options.skipBuild = true;
|
||||
break;
|
||||
case "--copy-config":
|
||||
options.copyConfig = true;
|
||||
break;
|
||||
case "--help":
|
||||
case "-h":
|
||||
options.help = true;
|
||||
@@ -361,35 +366,51 @@ async function startContainer({
|
||||
containerName,
|
||||
hostname,
|
||||
configDir,
|
||||
copyConfig,
|
||||
}) {
|
||||
const networkName = resolveComposeNetworkName(rootDir);
|
||||
const mountedConfigDir = toDockerMountPath(configDir);
|
||||
const containerConfigPath = copyConfig
|
||||
? `/tmp/${DEFAULT_CONFIG_FILE_NAME}`
|
||||
: `/config/${DEFAULT_CONFIG_FILE_NAME}`;
|
||||
const createArgs = [
|
||||
copyConfig ? "create" : "run",
|
||||
...(copyConfig ? [] : ["-d"]),
|
||||
"--name",
|
||||
containerName,
|
||||
"--hostname",
|
||||
hostname,
|
||||
"--restart",
|
||||
"unless-stopped",
|
||||
"--network",
|
||||
networkName,
|
||||
...(copyConfig ? [] : ["-v", `${mountedConfigDir}:/config`]),
|
||||
imageTag,
|
||||
"--config",
|
||||
containerConfigPath,
|
||||
];
|
||||
|
||||
await removeContainer(containerName);
|
||||
await runCommand(
|
||||
"docker",
|
||||
[
|
||||
"run",
|
||||
"-d",
|
||||
"--name",
|
||||
containerName,
|
||||
"--hostname",
|
||||
hostname,
|
||||
"--restart",
|
||||
"unless-stopped",
|
||||
"--network",
|
||||
networkName,
|
||||
"-v",
|
||||
`${mountedConfigDir}:/config`,
|
||||
imageTag,
|
||||
"--config",
|
||||
`/config/${DEFAULT_CONFIG_FILE_NAME}`,
|
||||
],
|
||||
{
|
||||
await runCommand("docker", createArgs, {
|
||||
cwd: rootDir,
|
||||
stdio: "inherit",
|
||||
});
|
||||
|
||||
if (copyConfig) {
|
||||
await runCommand("docker", [
|
||||
"cp",
|
||||
path.join(configDir, DEFAULT_CONFIG_FILE_NAME),
|
||||
`${containerName}:${containerConfigPath}`,
|
||||
], {
|
||||
cwd: rootDir,
|
||||
stdio: "inherit",
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
await runCommand("docker", ["start", containerName], {
|
||||
cwd: rootDir,
|
||||
stdio: "inherit",
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
async function printStatus({ imageTag, configDir, containerName }) {
|
||||
@@ -469,6 +490,7 @@ async function main() {
|
||||
containerName: options.containerName,
|
||||
hostname: options.hostname,
|
||||
configDir,
|
||||
copyConfig: options.copyConfig,
|
||||
});
|
||||
|
||||
process.stdout.write(`Test gateway container started.
|
||||
|
||||
Reference in New Issue
Block a user