-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.ts
More file actions
86 lines (83 loc) · 2.12 KB
/
index.ts
File metadata and controls
86 lines (83 loc) · 2.12 KB
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
import { Clerc, helpPlugin, versionPlugin } from "clerc";
import { deploy } from "./commands/deploy";
import { setup } from "./commands/setup";
import { ssh } from "./utils/ssh";
Clerc.create()
.scriptName("deploytool")
.description("Deploy tool")
.version("0.1.0")
.use(helpPlugin())
.use(versionPlugin())
.command("setup", "Set up a server for future deployment", {
parameters: ["<ip>"],
flags: {
sshUser: {
alias: "u",
type: String,
default: "root",
description: "SSH user",
},
},
})
.command("deploy", "Deploy a new version of a service", {
parameters: ["<ip>", "<domain>", "<image>", "<name>"],
flags: {
port: {
alias: "p",
type: String,
default: "80",
description: "Port the container listens to",
},
path: {
alias: "P",
type: String,
description: "Path prefix the service should handle",
},
sshUser: {
alias: "u",
type: String,
default: "root",
description: "SSH user",
},
environment: {
alias: "e",
type: [String],
description: "Environment variables",
},
registry: {
type: String,
description: "Docker registry server",
},
"registry-username": {
type: String,
description: "Docker registry username",
},
"registry-password": {
type: String,
description: "Docker registry password",
},
},
})
.on("setup", async (context) => {
const { ip } = context.parameters;
const { sshUser } = context.flags;
await setup(ssh(ip, sshUser), { ip });
})
.on("deploy", async (context) => {
const { ip, domain, image, name } = context.parameters;
const { port, path, sshUser, environment } = context.flags;
await deploy(ssh(ip, sshUser), {
domain,
image,
name,
port,
path,
environment,
registry: {
server: context.flags.registry,
username: context.flags["registry-username"],
password: context.flags["registry-password"],
},
});
})
.parse();