add nginx wrapper and refactor
This commit is contained in:
parent
9216063aa0
commit
6f92727bb3
9 changed files with 530 additions and 92 deletions
|
@ -1,13 +1,14 @@
|
|||
// wrapper
|
||||
|
||||
import { log_from, sleep } from "./utils.ts";
|
||||
import { ContainerConfigRedirection } from "./config.ts";
|
||||
|
||||
const log = log_from("nspawn");
|
||||
|
||||
export function container_command(name: string, directory: string, opts?: {
|
||||
veth?: boolean;
|
||||
boot?: boolean;
|
||||
ports?: ([number, number] | [number, number, "tcp" | "udp"])[];
|
||||
redirections?: ContainerConfigRedirection[];
|
||||
cmd_opts?: Deno.CommandOptions;
|
||||
syscall_filter?: string[];
|
||||
}) {
|
||||
|
@ -17,8 +18,12 @@ export function container_command(name: string, directory: string, opts?: {
|
|||
];
|
||||
if (opts?.veth ?? false) args.push("--network-veth");
|
||||
if (opts?.boot ?? false) args.push("--boot");
|
||||
for (const [from, to, proto] of opts?.ports ?? []) {
|
||||
args.push(proto === undefined ? `--port=${from}:${to}` : `--port=${proto}:${from}:${to}`);
|
||||
for (const redir of opts?.redirections ?? []) {
|
||||
if (redir.kind === "http") args.push(`--port=${redir.port}`);
|
||||
if (redir.kind === "port") {
|
||||
args.push(`--port=tcp:${redir.from}:${redir.to}`);
|
||||
args.push(`--port=udp:${redir.from}:${redir.to}`);
|
||||
}
|
||||
}
|
||||
for (const call of opts?.syscall_filter ?? []) args.push(`--system-call-filter=${call}`);
|
||||
const command = new Deno.Command("systemd-nspawn", { ...opts?.cmd_opts, args });
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue