@ossy/deployment-tools 0.0.6 → 0.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +43 -75
- package/package.json +1 -1
- package/src/Caddyfile +11 -15
- package/src/caddy-client.js +34 -68
- package/src/config.js +2 -1
- package/src/container-manager-server.js +1 -1
- package/src/index.js +2 -1
package/dist/index.js
CHANGED
|
@@ -28393,9 +28393,16 @@ function fixResponseChunkedTransferBadEnding(request, errorCallback) {
|
|
|
28393
28393
|
});
|
|
28394
28394
|
}
|
|
28395
28395
|
|
|
28396
|
+
;// CONCATENATED MODULE: ./src/config.js
|
|
28397
|
+
const domain = process.env.DEPLOYMENT_TOOLS_DOMAIN || 'localhost'
|
|
28398
|
+
const environmentName = process.env.DEPLOYMENT_TOOLS_ENVIRONMENT_NAME || 'dev'
|
|
28399
|
+
const ciSubDomain = process.env.DEPLOYMENT_TOOLS_CI_SUB_DOMAIN || 'ci'
|
|
28400
|
+
const port = process.env.DEPLOYMENT_TOOLS_PORT || 3000
|
|
28401
|
+
|
|
28396
28402
|
;// CONCATENATED MODULE: ./src/caddy-client.js
|
|
28397
28403
|
|
|
28398
28404
|
|
|
28405
|
+
|
|
28399
28406
|
const Matchers = {
|
|
28400
28407
|
host: host => ({ host: [host] }),
|
|
28401
28408
|
path: path => ({ path: [path] })
|
|
@@ -28412,81 +28419,22 @@ const Handlers = {
|
|
|
28412
28419
|
})
|
|
28413
28420
|
}
|
|
28414
28421
|
|
|
28415
|
-
const createRouteConfig = ({ domain, path, upstreamPort }) => ({
|
|
28416
|
-
match: [Matchers.host(domain)],
|
|
28417
|
-
handle: [
|
|
28418
|
-
{
|
|
28419
|
-
handler: 'subroute',
|
|
28420
|
-
routes: [
|
|
28421
|
-
{ handle: [Handlers.reverseProxy(upstreamPort)]}
|
|
28422
|
-
]
|
|
28423
|
-
}
|
|
28424
|
-
],
|
|
28425
|
-
terminal: true
|
|
28426
|
-
})
|
|
28427
|
-
|
|
28428
|
-
const multipleDomansAndSubroutes = () => ({
|
|
28429
|
-
apps: {
|
|
28430
|
-
http: {
|
|
28431
|
-
servers: {
|
|
28432
|
-
'ci-client': {
|
|
28433
|
-
listen: [
|
|
28434
|
-
':443'
|
|
28435
|
-
],
|
|
28436
|
-
routes: [
|
|
28437
|
-
{
|
|
28438
|
-
match: [Matchers.host('admin.localhost')],
|
|
28439
|
-
handle: [
|
|
28440
|
-
Handlers.subroute([{ handle: [Handlers.reverseProxy(3000)] }])
|
|
28441
|
-
],
|
|
28442
|
-
terminal: true
|
|
28443
|
-
},
|
|
28444
|
-
{
|
|
28445
|
-
match: [Matchers.host('cms.localhost')],
|
|
28446
|
-
handle: [
|
|
28447
|
-
Handlers.subroute([{ handle: [Handlers.reverseProxy(3005)] }])
|
|
28448
|
-
],
|
|
28449
|
-
terminal: true
|
|
28450
|
-
},
|
|
28451
|
-
{
|
|
28452
|
-
match: [Matchers.host('localhost')],
|
|
28453
|
-
handle: [
|
|
28454
|
-
Handlers.subroute([
|
|
28455
|
-
{
|
|
28456
|
-
handle: [Handlers.reverseProxy(3001)],
|
|
28457
|
-
match: [Matchers.path('/api/*')]
|
|
28458
|
-
},
|
|
28459
|
-
{ handle: [Handlers.reverseProxy(3000)] }
|
|
28460
|
-
])
|
|
28461
|
-
],
|
|
28462
|
-
terminal: true
|
|
28463
|
-
}
|
|
28464
|
-
]
|
|
28465
|
-
}
|
|
28466
|
-
}
|
|
28467
|
-
}
|
|
28468
|
-
}
|
|
28469
|
-
})
|
|
28470
|
-
|
|
28471
|
-
// curl localhost:2019/id/msg
|
|
28472
|
-
|
|
28473
28422
|
class CaddyClient {
|
|
28474
28423
|
|
|
28475
28424
|
constructor(serverName = 'ci-client') {
|
|
28476
28425
|
this.serverName = serverName
|
|
28477
28426
|
}
|
|
28478
28427
|
|
|
28479
|
-
deploy({ domain,
|
|
28480
|
-
return fetch(`http://localhost:2019/config/apps/http/servers/${this.serverName}/routes`, {
|
|
28428
|
+
deploy({ domain, targetPort }) {
|
|
28429
|
+
return fetch(`http://localhost:2019/config/apps/http/servers/${this.serverName}/routes/0/handle`, {
|
|
28481
28430
|
method: 'POST',
|
|
28482
28431
|
headers: { 'Content-Type': 'application/json' },
|
|
28483
|
-
body: JSON.stringify(
|
|
28484
|
-
|
|
28485
|
-
|
|
28486
|
-
Handlers.subroute([{ handle: [Handlers.reverseProxy(targetPort)]
|
|
28487
|
-
|
|
28488
|
-
|
|
28489
|
-
})
|
|
28432
|
+
body: JSON.stringify( Handlers.subroute([
|
|
28433
|
+
{
|
|
28434
|
+
match: [Matchers.host(domain)],
|
|
28435
|
+
handle: [Handlers.subroute([{ handle: [Handlers.reverseProxy(targetPort)]}])]
|
|
28436
|
+
}
|
|
28437
|
+
]))
|
|
28490
28438
|
})
|
|
28491
28439
|
}
|
|
28492
28440
|
|
|
@@ -28500,7 +28448,31 @@ class CaddyClient {
|
|
|
28500
28448
|
servers: {
|
|
28501
28449
|
[this.serverName]: {
|
|
28502
28450
|
listen: [':443'],
|
|
28503
|
-
routes: [
|
|
28451
|
+
routes: [
|
|
28452
|
+
{
|
|
28453
|
+
match: [Matchers.host(`*.${environmentName}.${domain}`)],
|
|
28454
|
+
handle: [],
|
|
28455
|
+
terminal: true
|
|
28456
|
+
}
|
|
28457
|
+
]
|
|
28458
|
+
}
|
|
28459
|
+
}
|
|
28460
|
+
},
|
|
28461
|
+
tls: {
|
|
28462
|
+
automation: {
|
|
28463
|
+
policies: {
|
|
28464
|
+
issuers: [
|
|
28465
|
+
{
|
|
28466
|
+
module: 'acme',
|
|
28467
|
+
challenges: {
|
|
28468
|
+
dns: {
|
|
28469
|
+
provider: {
|
|
28470
|
+
name: 'route53'
|
|
28471
|
+
}
|
|
28472
|
+
}
|
|
28473
|
+
}
|
|
28474
|
+
}
|
|
28475
|
+
]
|
|
28504
28476
|
}
|
|
28505
28477
|
}
|
|
28506
28478
|
}
|
|
@@ -28650,11 +28622,6 @@ ${this.startContainer({ image, containerPort, hostPort, registry, env })}`
|
|
|
28650
28622
|
|
|
28651
28623
|
const createDockerClient = () => new DockerClient()
|
|
28652
28624
|
|
|
28653
|
-
;// CONCATENATED MODULE: ./src/config.js
|
|
28654
|
-
const domain = process.env.DEPLOYMENT_TOOLS_DOMAIN || 'localhost'
|
|
28655
|
-
const subdomain = process.env.DEPLOYMENT_TOOLS_SUBDOMAIN || 'local-dev.ci'
|
|
28656
|
-
const port = process.env.DEPLOYMENT_TOOLS_PORT || 3000
|
|
28657
|
-
|
|
28658
28625
|
;// CONCATENATED MODULE: ./src/container-manager-server.js
|
|
28659
28626
|
|
|
28660
28627
|
|
|
@@ -28676,7 +28643,7 @@ class ContainerManagerServer {
|
|
|
28676
28643
|
|
|
28677
28644
|
this.caddyClient.applyDefaultServerConfig()
|
|
28678
28645
|
.then(() => this.caddyClient.deploy({
|
|
28679
|
-
domain: `${
|
|
28646
|
+
domain: `${ciSubDomain}.${environmentName}.${domain}`,
|
|
28680
28647
|
targetPort: port
|
|
28681
28648
|
}))
|
|
28682
28649
|
|
|
@@ -28880,7 +28847,8 @@ After=network.target
|
|
|
28880
28847
|
|
|
28881
28848
|
[Service]
|
|
28882
28849
|
Environment=DEPLOYMENT_TOOLS_DOMAIN=${domain}
|
|
28883
|
-
Environment=
|
|
28850
|
+
Environment=DEPLOYMENT_TOOLS_ENVIRONMENT_NAME=${environmentName}
|
|
28851
|
+
Environment=DEPLOYMENT_TOOLS_CI_SUB_DOMAIN=${ciSubDomain}
|
|
28884
28852
|
Environment=DEPLOYMENT_TOOLS_PORT=${port}
|
|
28885
28853
|
User=root
|
|
28886
28854
|
ExecStart=npx @ossy/deployment-tools start-container-manager
|
package/package.json
CHANGED
package/src/Caddyfile
CHANGED
|
@@ -1,22 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
reverse_proxy /api/* {
|
|
3
|
-
to localhost:3001
|
|
4
|
-
}
|
|
1
|
+
*.qa.ossy.com {
|
|
5
2
|
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
tls {
|
|
4
|
+
dns 123123
|
|
8
5
|
}
|
|
9
6
|
|
|
10
|
-
|
|
7
|
+
@foo host ci.qa.example.com
|
|
8
|
+
handle @foo {
|
|
9
|
+
reverse_proxy * {
|
|
10
|
+
to localhost:3005
|
|
11
|
+
}
|
|
12
|
+
}
|
|
11
13
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
to localhost:3005
|
|
14
|
+
handle {
|
|
15
|
+
respond "Wrong turn!"
|
|
15
16
|
}
|
|
16
|
-
}
|
|
17
17
|
|
|
18
|
-
admin.localhost {
|
|
19
|
-
reverse_proxy * {
|
|
20
|
-
to localhost:3000
|
|
21
|
-
}
|
|
22
18
|
}
|
package/src/caddy-client.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import fetch from 'node-fetch'
|
|
2
|
+
import * as config from './config.js'
|
|
2
3
|
|
|
3
4
|
const Matchers = {
|
|
4
5
|
host: host => ({ host: [host] }),
|
|
@@ -16,81 +17,22 @@ const Handlers = {
|
|
|
16
17
|
})
|
|
17
18
|
}
|
|
18
19
|
|
|
19
|
-
const createRouteConfig = ({ domain, path, upstreamPort }) => ({
|
|
20
|
-
match: [Matchers.host(domain)],
|
|
21
|
-
handle: [
|
|
22
|
-
{
|
|
23
|
-
handler: 'subroute',
|
|
24
|
-
routes: [
|
|
25
|
-
{ handle: [Handlers.reverseProxy(upstreamPort)]}
|
|
26
|
-
]
|
|
27
|
-
}
|
|
28
|
-
],
|
|
29
|
-
terminal: true
|
|
30
|
-
})
|
|
31
|
-
|
|
32
|
-
const multipleDomansAndSubroutes = () => ({
|
|
33
|
-
apps: {
|
|
34
|
-
http: {
|
|
35
|
-
servers: {
|
|
36
|
-
'ci-client': {
|
|
37
|
-
listen: [
|
|
38
|
-
':443'
|
|
39
|
-
],
|
|
40
|
-
routes: [
|
|
41
|
-
{
|
|
42
|
-
match: [Matchers.host('admin.localhost')],
|
|
43
|
-
handle: [
|
|
44
|
-
Handlers.subroute([{ handle: [Handlers.reverseProxy(3000)] }])
|
|
45
|
-
],
|
|
46
|
-
terminal: true
|
|
47
|
-
},
|
|
48
|
-
{
|
|
49
|
-
match: [Matchers.host('cms.localhost')],
|
|
50
|
-
handle: [
|
|
51
|
-
Handlers.subroute([{ handle: [Handlers.reverseProxy(3005)] }])
|
|
52
|
-
],
|
|
53
|
-
terminal: true
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
match: [Matchers.host('localhost')],
|
|
57
|
-
handle: [
|
|
58
|
-
Handlers.subroute([
|
|
59
|
-
{
|
|
60
|
-
handle: [Handlers.reverseProxy(3001)],
|
|
61
|
-
match: [Matchers.path('/api/*')]
|
|
62
|
-
},
|
|
63
|
-
{ handle: [Handlers.reverseProxy(3000)] }
|
|
64
|
-
])
|
|
65
|
-
],
|
|
66
|
-
terminal: true
|
|
67
|
-
}
|
|
68
|
-
]
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
})
|
|
74
|
-
|
|
75
|
-
// curl localhost:2019/id/msg
|
|
76
|
-
|
|
77
20
|
class CaddyClient {
|
|
78
21
|
|
|
79
22
|
constructor(serverName = 'ci-client') {
|
|
80
23
|
this.serverName = serverName
|
|
81
24
|
}
|
|
82
25
|
|
|
83
|
-
deploy({ domain,
|
|
84
|
-
return fetch(`http://localhost:2019/config/apps/http/servers/${this.serverName}/routes`, {
|
|
26
|
+
deploy({ domain, targetPort }) {
|
|
27
|
+
return fetch(`http://localhost:2019/config/apps/http/servers/${this.serverName}/routes/0/handle`, {
|
|
85
28
|
method: 'POST',
|
|
86
29
|
headers: { 'Content-Type': 'application/json' },
|
|
87
|
-
body: JSON.stringify(
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
Handlers.subroute([{ handle: [Handlers.reverseProxy(targetPort)]
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
})
|
|
30
|
+
body: JSON.stringify( Handlers.subroute([
|
|
31
|
+
{
|
|
32
|
+
match: [Matchers.host(domain)],
|
|
33
|
+
handle: [Handlers.subroute([{ handle: [Handlers.reverseProxy(targetPort)]}])]
|
|
34
|
+
}
|
|
35
|
+
]))
|
|
94
36
|
})
|
|
95
37
|
}
|
|
96
38
|
|
|
@@ -104,7 +46,31 @@ class CaddyClient {
|
|
|
104
46
|
servers: {
|
|
105
47
|
[this.serverName]: {
|
|
106
48
|
listen: [':443'],
|
|
107
|
-
routes: [
|
|
49
|
+
routes: [
|
|
50
|
+
{
|
|
51
|
+
match: [Matchers.host(`*.${config.environmentName}.${config.domain}`)],
|
|
52
|
+
handle: [],
|
|
53
|
+
terminal: true
|
|
54
|
+
}
|
|
55
|
+
]
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
tls: {
|
|
60
|
+
automation: {
|
|
61
|
+
policies: {
|
|
62
|
+
issuers: [
|
|
63
|
+
{
|
|
64
|
+
module: 'acme',
|
|
65
|
+
challenges: {
|
|
66
|
+
dns: {
|
|
67
|
+
provider: {
|
|
68
|
+
name: 'route53'
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
]
|
|
108
74
|
}
|
|
109
75
|
}
|
|
110
76
|
}
|
package/src/config.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export const domain = process.env.DEPLOYMENT_TOOLS_DOMAIN || 'localhost'
|
|
2
|
-
export const
|
|
2
|
+
export const environmentName = process.env.DEPLOYMENT_TOOLS_ENVIRONMENT_NAME || 'dev'
|
|
3
|
+
export const ciSubDomain = process.env.DEPLOYMENT_TOOLS_CI_SUB_DOMAIN || 'ci'
|
|
3
4
|
export const port = process.env.DEPLOYMENT_TOOLS_PORT || 3000
|
|
@@ -18,7 +18,7 @@ export class ContainerManagerServer {
|
|
|
18
18
|
|
|
19
19
|
this.caddyClient.applyDefaultServerConfig()
|
|
20
20
|
.then(() => this.caddyClient.deploy({
|
|
21
|
-
domain: `${config.
|
|
21
|
+
domain: `${config.ciSubDomain}.${config.environmentName}.${config.domain}`,
|
|
22
22
|
targetPort: config.port
|
|
23
23
|
}))
|
|
24
24
|
|
package/src/index.js
CHANGED
|
@@ -28,7 +28,8 @@ After=network.target
|
|
|
28
28
|
|
|
29
29
|
[Service]
|
|
30
30
|
Environment=DEPLOYMENT_TOOLS_DOMAIN=${config.domain}
|
|
31
|
-
Environment=
|
|
31
|
+
Environment=DEPLOYMENT_TOOLS_ENVIRONMENT_NAME=${config.environmentName}
|
|
32
|
+
Environment=DEPLOYMENT_TOOLS_CI_SUB_DOMAIN=${config.ciSubDomain}
|
|
32
33
|
Environment=DEPLOYMENT_TOOLS_PORT=${config.port}
|
|
33
34
|
User=root
|
|
34
35
|
ExecStart=npx @ossy/deployment-tools start-container-manager
|