@marinoscar/platform-cli 0.1.0-next.12 → 0.1.0-next.13
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/CHANGELOG.md +11 -0
- package/dist/deploy/index.d.ts +1 -1
- package/dist/deploy/index.d.ts.map +1 -1
- package/dist/engine/deploy/checks/compose.d.ts +7 -0
- package/dist/engine/deploy/checks/compose.d.ts.map +1 -0
- package/dist/engine/deploy/checks/compose.js +149 -0
- package/dist/engine/deploy/checks/compose.js.map +1 -0
- package/dist/engine/deploy/checks/index.d.ts +1 -0
- package/dist/engine/deploy/checks/index.d.ts.map +1 -1
- package/dist/engine/deploy/checks/index.js +4 -0
- package/dist/engine/deploy/checks/index.js.map +1 -1
- package/dist/engine/deploy/compose-containers.d.ts +72 -0
- package/dist/engine/deploy/compose-containers.d.ts.map +1 -0
- package/dist/engine/deploy/compose-containers.js +125 -0
- package/dist/engine/deploy/compose-containers.js.map +1 -0
- package/dist/engine/deploy/compose-project.d.ts +38 -32
- package/dist/engine/deploy/compose-project.d.ts.map +1 -1
- package/dist/engine/deploy/compose-project.js +78 -100
- package/dist/engine/deploy/compose-project.js.map +1 -1
- package/dist/engine/deploy/install.d.ts.map +1 -1
- package/dist/engine/deploy/install.js +47 -7
- package/dist/engine/deploy/install.js.map +1 -1
- package/dist/engine/deploy/testing/fake-containers.d.ts +18 -0
- package/dist/engine/deploy/testing/fake-containers.d.ts.map +1 -0
- package/dist/engine/deploy/testing/fake-containers.js +25 -0
- package/dist/engine/deploy/testing/fake-containers.js.map +1 -0
- package/dist/engine/deploy/update.d.ts.map +1 -1
- package/dist/engine/deploy/update.js +12 -1
- package/dist/engine/deploy/update.js.map +1 -1
- package/dist/engine/index.d.ts +1 -1
- package/dist/engine/index.d.ts.map +1 -1
- package/dist/engine/index.js.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @marinoscar/platform-cli
|
|
2
2
|
|
|
3
|
+
## 0.1.0-next.13
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 1da0964: `deploy update` no longer starts a second stack when the deploy folder holds containers of two compose projects. A folder with the live stack under an app-named project (for example `kvox-nginx-1` on the bind port) and leftover containers of the legacy `compose` project was read as ambiguous and kept `compose`, so `docker compose -p compose up -d` built a parallel stack that died on `Bind for 127.0.0.1:3535 failed: port is already allocated`. The project is now picked by the strongest evidence among the containers started from the deploy folder: the project whose container publishes the bind port (running containers first), then the only project with a running container, then the only project, and is recorded in `.appctl-deploy.json` when the state has none or the legacy `compose`. When nothing separates the projects the record is kept and a warning names the projects and the state file; a recorded project is never overwritten, but a warning is printed when another project holds the bind port. `install --resume` and `--reinstall` reconcile the same way before their first compose or check call. `detectComposeProject` takes an optional `{ bindPort }` and a `found` result carries the `basis` that decided it (`bind-port`, `running` or `only`).
|
|
8
|
+
|
|
9
|
+
New required check `bind-port-owner` (the `update` and `install` preflight, and `doctor`): any container in any state that publishes the bind port under a compose project other than the one the run would use fails the run before anything is built, naming both projects, the `composeProject` fix in the state file and the exact `docker ps -aq ... | xargs -r docker rm -f` command for leftovers; a port promised to an unrelated container points to `--port`. New recommended check `stray-compose-stack` warns in `doctor` about containers of another project started from the deploy folder, with the same removal command. A stopped leftover of the deploy folder is only a warning (printed during `update`, with the removal command) when a running container of the run's own project holds the port; a running foreign container, or a stopped one with no live own holder, still fails. Neither check removes anything. The `update` preflight failure now prints each failed check's remedy, as `install` does. Apps that carry their own copy of a "port promised to another project" check can drop it.
|
|
10
|
+
|
|
11
|
+
- @marinoscar/platform-contract@0.1.0-next.13
|
|
12
|
+
- @marinoscar/platform-infra@0.1.0-next.13
|
|
13
|
+
|
|
3
14
|
## 0.1.0-next.12
|
|
4
15
|
|
|
5
16
|
### Patch Changes
|
package/dist/deploy/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { DEFAULT_STREAM_TIMEOUT_SECONDS, DEPLOY_STATE_FILENAME, ENV_GROUPS, INSTALL_STEP_IDS, PLATFORM_DOCUMENTED_OPTIONAL_KEYS, PLATFORM_STREAM_PATHS, PROXY_MANAGED_SENTINEL, UPDATE_STEP_IDS, assertValidProxyPath, builtinDeployStepIds, commentedAssignments, composeEnvSpecs, detectComposeProject, edgeConfigFiles, effectiveGroups, isPathUnder, listDeployCheckIds, listRegisteredDeployChecks, listRegisteredDeploySteps, listRegisteredProxyStreamPaths, metadataFor, parseEnvExample, planDeploySteps, registerDeployCheck, registerDeployStep, registerEdgeConfigFile, registerProxyStreamPath, } from '../engine/index.js';
|
|
2
|
-
export type { AppDeployStepRegistration, BuiltinEnvGroup, ComposeProjectCommandRunner, ComposeProjectDetection, DeployCheckContext, DeployCheckResult, EnvGroup, EnvVarMetadata, AppDeployStep, DeployCheck, DeployCommandResult, DeployHooks, DeployPipeline, DeployPlanStep, DeployStepContext, DeployStepRegistration, DeployStepValues, EdgeConfigFile, EnvVarSpec, ProxyExtraLocation, ProxyStreamPathRegistration, StepOutcome, StepResult, } from '../engine/index.js';
|
|
2
|
+
export type { AppDeployStepRegistration, BuiltinEnvGroup, ComposeContainer, ComposeProjectBasis, ComposeProjectCommandRunner, ComposeProjectDetection, DeployCheckContext, DeployCheckResult, EnvGroup, EnvVarMetadata, AppDeployStep, DeployCheck, DeployCommandResult, DeployHooks, DeployPipeline, DeployPlanStep, DeployStepContext, DeployStepRegistration, DeployStepValues, EdgeConfigFile, EnvVarSpec, ProxyExtraLocation, ProxyStreamPathRegistration, StepOutcome, StepResult, } from '../engine/index.js';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/deploy/index.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,8BAA8B,EAC9B,qBAAqB,EACrB,UAAU,EACV,gBAAgB,EAChB,iCAAiC,EACjC,qBAAqB,EACrB,sBAAsB,EACtB,eAAe,EACf,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,EACpB,eAAe,EACf,oBAAoB,EACpB,eAAe,EACf,eAAe,EACf,WAAW,EACX,kBAAkB,EAClB,0BAA0B,EAC1B,yBAAyB,EACzB,8BAA8B,EAC9B,WAAW,EACX,eAAe,EACf,eAAe,EACf,mBAAmB,EACnB,kBAAkB,EAClB,sBAAsB,EACtB,uBAAuB,GACxB,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EACV,yBAAyB,EACzB,eAAe,EACf,2BAA2B,EAC3B,uBAAuB,EACvB,kBAAkB,EAClB,iBAAiB,EACjB,QAAQ,EACR,cAAc,EACd,aAAa,EACb,WAAW,EACX,mBAAmB,EACnB,WAAW,EACX,cAAc,EACd,cAAc,EACd,iBAAiB,EACjB,sBAAsB,EACtB,gBAAgB,EAChB,cAAc,EACd,UAAU,EACV,kBAAkB,EAClB,2BAA2B,EAC3B,WAAW,EACX,UAAU,GACX,MAAM,oBAAoB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/deploy/index.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,8BAA8B,EAC9B,qBAAqB,EACrB,UAAU,EACV,gBAAgB,EAChB,iCAAiC,EACjC,qBAAqB,EACrB,sBAAsB,EACtB,eAAe,EACf,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,EACpB,eAAe,EACf,oBAAoB,EACpB,eAAe,EACf,eAAe,EACf,WAAW,EACX,kBAAkB,EAClB,0BAA0B,EAC1B,yBAAyB,EACzB,8BAA8B,EAC9B,WAAW,EACX,eAAe,EACf,eAAe,EACf,mBAAmB,EACnB,kBAAkB,EAClB,sBAAsB,EACtB,uBAAuB,GACxB,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EACV,yBAAyB,EACzB,eAAe,EACf,gBAAgB,EAChB,mBAAmB,EACnB,2BAA2B,EAC3B,uBAAuB,EACvB,kBAAkB,EAClB,iBAAiB,EACjB,QAAQ,EACR,cAAc,EACd,aAAa,EACb,WAAW,EACX,mBAAmB,EACnB,WAAW,EACX,cAAc,EACd,cAAc,EACd,iBAAiB,EACjB,sBAAsB,EACtB,gBAAgB,EAChB,cAAc,EACd,UAAU,EACV,kBAAkB,EAClB,2BAA2B,EAC3B,WAAW,EACX,UAAU,GACX,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Check } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* The compose-project checks: `bind-port-owner` (required) and
|
|
4
|
+
* `stray-compose-stack` (recommended, so `doctor` only).
|
|
5
|
+
*/
|
|
6
|
+
export declare const COMPOSE_CHECKS: readonly Check[];
|
|
7
|
+
//# sourceMappingURL=compose.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compose.d.ts","sourceRoot":"","sources":["../../../../src/engine/deploy/checks/compose.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,KAAK,EAA6B,MAAM,YAAY,CAAC;AA6KnE;;;GAGG;AACH,eAAO,MAAM,cAAc,EAAE,SAAS,KAAK,EAAuC,CAAC"}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { basename } from 'node:path';
|
|
2
|
+
import { freshComposeProject, isPathUnder, listComposeContainers, publishesPort, } from '../compose-containers.js';
|
|
3
|
+
import { deployStatePath } from '../state.js';
|
|
4
|
+
// =============================================================================
|
|
5
|
+
// Does this run's compose project match the stack that holds the port? (#1020)
|
|
6
|
+
// =============================================================================
|
|
7
|
+
//
|
|
8
|
+
// `docker compose -p <wrong project> up -d` builds a SECOND stack beside the
|
|
9
|
+
// live one and dies on the bind port the live one holds -- after the build, and
|
|
10
|
+
// after the parallel stack's other services have already started. Every
|
|
11
|
+
// project-name mistake ends there, so the question is asked up front, from what
|
|
12
|
+
// Docker says rather than from what the state file records: does any container,
|
|
13
|
+
// in any state, publish this deployment's bind port under a project other than
|
|
14
|
+
// the one this run will pass to `-p`?
|
|
15
|
+
//
|
|
16
|
+
// Read-only, like every check. The removal command is TEXT in a remedy; no
|
|
17
|
+
// check ever removes anything.
|
|
18
|
+
// =============================================================================
|
|
19
|
+
/** The command that removes the containers of `project` started from `workingDir`. */
|
|
20
|
+
function removalCommand(project, workingDir) {
|
|
21
|
+
return ('docker ps -aq' +
|
|
22
|
+
` --filter label=com.docker.compose.project=${project}` +
|
|
23
|
+
` --filter label=com.docker.compose.project.working_dir=${workingDir}` +
|
|
24
|
+
' | xargs -r docker rm -f');
|
|
25
|
+
}
|
|
26
|
+
/** The project this run uses: the recorded one, else the name a fresh install would take. */
|
|
27
|
+
function runProject(context) {
|
|
28
|
+
return context.composeProject ?? freshComposeProject(context.deployRoot);
|
|
29
|
+
}
|
|
30
|
+
/** A container as a short phrase: `name (project P)`, or `name (not a compose container)`. */
|
|
31
|
+
function describeHolder(container) {
|
|
32
|
+
return container.project === ''
|
|
33
|
+
? `${container.name} (not a compose container)`
|
|
34
|
+
: `${container.name} (project ${container.project})`;
|
|
35
|
+
}
|
|
36
|
+
/** The lines of a list, deduplicated and in order. */
|
|
37
|
+
function unique(values) {
|
|
38
|
+
return [...new Set(values)];
|
|
39
|
+
}
|
|
40
|
+
const bindPortOwner = {
|
|
41
|
+
id: 'bind-port-owner',
|
|
42
|
+
title: "Bind port held by this deployment's compose project",
|
|
43
|
+
severity: 'required',
|
|
44
|
+
requires: ['docker-daemon'],
|
|
45
|
+
async run(context) {
|
|
46
|
+
const containers = await listComposeContainers(context.runCommand);
|
|
47
|
+
if (containers === undefined) {
|
|
48
|
+
return { status: 'skip', detail: 'Docker could not be asked which containers publish the port' };
|
|
49
|
+
}
|
|
50
|
+
const claimants = containers.filter((container) => publishesPort(container, context.bindPort));
|
|
51
|
+
if (claimants.length === 0) {
|
|
52
|
+
return { status: 'pass', detail: `no container publishes port ${context.bindPort}` };
|
|
53
|
+
}
|
|
54
|
+
// A fresh install has no record: the only project that may hold the port is
|
|
55
|
+
// the one it is about to create, and only from inside its own folder.
|
|
56
|
+
const expected = runProject(context);
|
|
57
|
+
const foreign = claimants.filter((container) => context.composeProject === undefined
|
|
58
|
+
? !(container.project === expected && container.workingDir !== '' && isPathUnder(container.workingDir, context.deployRoot))
|
|
59
|
+
: container.project !== expected);
|
|
60
|
+
if (foreign.length === 0) {
|
|
61
|
+
return { status: 'pass', detail: `held by this deployment (${unique(claimants.map((c) => c.name)).join(', ')})` };
|
|
62
|
+
}
|
|
63
|
+
const inRoot = (container) => container.workingDir !== '' && isPathUnder(container.workingDir, context.deployRoot);
|
|
64
|
+
// ⚠ A LIVE HOLDER OF THIS RUN'S OWN PROJECT PROVES THE RUN CANNOT COLLIDE
|
|
65
|
+
// WITH A STOPPED LEFTOVER of this folder: `up -d` under the run's project
|
|
66
|
+
// leaves the leftover alone, and Docker allocates the port only to running
|
|
67
|
+
// containers, so the live stack keeps it. That is housekeeping, not a
|
|
68
|
+
// blocker (a leftover created by a failed run is configured to publish the
|
|
69
|
+
// port too). Without such a holder the same leftover blocks: `up -d` could
|
|
70
|
+
// start OUR container while the leftover holds the promise, or the
|
|
71
|
+
// claimant is a different app. A RUNNING foreign claimant always blocks.
|
|
72
|
+
const ownHolderRuns = context.composeProject !== undefined &&
|
|
73
|
+
claimants.some((container) => container.project === expected && container.running);
|
|
74
|
+
const blocking = ownHolderRuns ? foreign.filter((container) => container.running || !inRoot(container)) : foreign;
|
|
75
|
+
const leftovers = foreign.filter((container) => !blocking.includes(container));
|
|
76
|
+
if (blocking.length === 0) {
|
|
77
|
+
const commands = unique(leftovers.map((c) => removalCommand(c.project, c.workingDir)));
|
|
78
|
+
return {
|
|
79
|
+
status: 'warn',
|
|
80
|
+
detail: `${unique(leftovers.map((c) => `${c.name} (project ${c.project})`)).join(', ')} ` +
|
|
81
|
+
`${leftovers.length === 1 ? 'is a stopped leftover' : 'are stopped leftovers'} still configured to publish port ${context.bindPort}; ` +
|
|
82
|
+
`this deployment's stack runs under ${expected}, so this run does not collide with ${leftovers.length === 1 ? 'it' : 'them'}`,
|
|
83
|
+
remedy: `Remove the leftover${leftovers.length === 1 ? '' : 's'}: ${commands.join(' ; ')}`,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
// Containers of this folder come first: they are the "second stack" case.
|
|
87
|
+
const ours = blocking.filter(inRoot);
|
|
88
|
+
const [leader] = ours;
|
|
89
|
+
if (leader !== undefined) {
|
|
90
|
+
const projects = unique(ours.map((c) => c.project));
|
|
91
|
+
const commands = unique(ours.map((c) => removalCommand(c.project, c.workingDir)));
|
|
92
|
+
const statePath = deployStatePath(context.deployRoot);
|
|
93
|
+
return {
|
|
94
|
+
status: 'fail',
|
|
95
|
+
detail: `this deployment's stack runs under project ${projects.join(', ')} but this run would use ${expected}; ` +
|
|
96
|
+
`a second stack would collide on port ${context.bindPort} ` +
|
|
97
|
+
`(${unique(ours.map((c) => `${c.name}${c.running ? '' : ', not running'}`)).join('; ')})`,
|
|
98
|
+
remedy: `Set "composeProject" to ${projects.join(' or ')} in ${statePath} if that is the live stack; ` +
|
|
99
|
+
`if those containers are leftovers, remove them with: ${commands.join(' ; ')}`,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
const [holder] = blocking;
|
|
103
|
+
return {
|
|
104
|
+
status: 'fail',
|
|
105
|
+
detail: `port ${context.bindPort} is promised to ${holder === undefined ? 'another container' : describeHolder(holder)}`,
|
|
106
|
+
remedy: `Choose another port with --port (or APP_BIND_PORT in .env), or remove ${unique(blocking.map((c) => c.name)).join(', ')} ` +
|
|
107
|
+
`if it is not needed (docker rm -f ${unique(blocking.map((c) => c.name)).join(' ')}).`,
|
|
108
|
+
};
|
|
109
|
+
},
|
|
110
|
+
};
|
|
111
|
+
const strayComposeStack = {
|
|
112
|
+
id: 'stray-compose-stack',
|
|
113
|
+
title: 'No leftover containers of another compose project',
|
|
114
|
+
severity: 'recommended',
|
|
115
|
+
requires: ['docker-daemon'],
|
|
116
|
+
async run(context) {
|
|
117
|
+
// Nothing to compare against before any state exists.
|
|
118
|
+
if (context.composeProject === undefined) {
|
|
119
|
+
return { status: 'skip', detail: 'no compose project is known for this deployment yet' };
|
|
120
|
+
}
|
|
121
|
+
const containers = await listComposeContainers(context.runCommand);
|
|
122
|
+
if (containers === undefined) {
|
|
123
|
+
return { status: 'skip', detail: 'Docker could not be asked which containers exist' };
|
|
124
|
+
}
|
|
125
|
+
const strays = containers.filter((container) => container.project !== '' &&
|
|
126
|
+
container.project !== context.composeProject &&
|
|
127
|
+
container.workingDir !== '' &&
|
|
128
|
+
isPathUnder(container.workingDir, context.deployRoot));
|
|
129
|
+
if (strays.length === 0) {
|
|
130
|
+
return { status: 'pass', detail: `every container of ${basename(context.deployRoot)} is of project ${context.composeProject}` };
|
|
131
|
+
}
|
|
132
|
+
const projects = unique(strays.map((c) => c.project));
|
|
133
|
+
const commands = unique(strays.map((c) => removalCommand(c.project, c.workingDir)));
|
|
134
|
+
return {
|
|
135
|
+
status: 'warn',
|
|
136
|
+
detail: `${strays.length} container${strays.length === 1 ? '' : 's'} of project ${projects.join(', ')} ` +
|
|
137
|
+
`started from ${context.deployRoot}, which runs under ${context.composeProject} ` +
|
|
138
|
+
`(${unique(strays.map((c) => `${c.name}${c.running ? '' : ', not running'}`)).join('; ')})`,
|
|
139
|
+
remedy: `If they are leftovers, remove them: ${commands.join(' ; ')}. ` +
|
|
140
|
+
`If they are the live stack, set "composeProject" in ${deployStatePath(context.deployRoot)} instead.`,
|
|
141
|
+
};
|
|
142
|
+
},
|
|
143
|
+
};
|
|
144
|
+
/**
|
|
145
|
+
* The compose-project checks: `bind-port-owner` (required) and
|
|
146
|
+
* `stray-compose-stack` (recommended, so `doctor` only).
|
|
147
|
+
*/
|
|
148
|
+
export const COMPOSE_CHECKS = [bindPortOwner, strayComposeStack];
|
|
149
|
+
//# sourceMappingURL=compose.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compose.js","sourceRoot":"","sources":["../../../../src/engine/deploy/checks/compose.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AO,CAAC,cAAc,GAAG;gBACjF,IAAI,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,eAAe,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG;YAC7F,MAAM,EACJ,uCAAuC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI;gBAC/D,uDAAuD,eAAe,CAAC,OAAO,CAAC,UAAU,CAAC,WAAW;SACxG,CAAC;IACJ,CAAC;CACF,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAqB,CAAC,aAAa,EAAE,iBAAiB,CAAC,CAAC"}
|
|
@@ -26,6 +26,7 @@ export declare function requiredChecks(checks?: readonly Check[], context?: Chec
|
|
|
26
26
|
export * from './types.js';
|
|
27
27
|
export { freezeDeployCheckRegistry, listRegisteredDeployChecks, registerDeployCheck, resetDeployCheckRegistryForTests, type DeployCheck, type DeployCheckContext, type DeployCheckResult, } from './registry.js';
|
|
28
28
|
export { HOST_CHECKS, evaluateDf, probe } from './host.js';
|
|
29
|
+
export { COMPOSE_CHECKS } from './compose.js';
|
|
29
30
|
export { SOURCE_CHECKS, SOURCE_CHECK_IDS, gitCredentialStateFor, gitHasCredentialFor, isHttpsGithubUrl, needsGithubCli, nonInteractiveGitEnv, } from './source.js';
|
|
30
31
|
export { DATABASE_CHECKS, MAINTENANCE_DATABASE, canCreateDatabase, databaseSettings, probeTcp, readRoleAttributes, runPsql, runPsqlScript, type CreateDatabaseCapability, type DatabaseSettings, type PsqlResult, type RoleAttributes, } from './database.js';
|
|
31
32
|
export { DNS_CHECKS } from './dns.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/engine/deploy/checks/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/engine/deploy/checks/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAqBtD,eAAO,MAAM,UAAU,EAAE,SAAS,KAAK,EAStC,CAAC;AAIF;;;;GAIG;AACH,wBAAgB,SAAS,IAAI,SAAS,KAAK,EAAE,CAG5C;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,IAAI,SAAS,MAAM,EAAE,CAEtD;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAC5B,MAAM,GAAE,SAAS,KAAK,EAAe,EACrC,OAAO,CAAC,EAAE,YAAY,GACrB,KAAK,EAAE,CAMT;AAED,cAAc,YAAY,CAAC;AAC3B,OAAO,EACL,yBAAyB,EACzB,0BAA0B,EAC1B,mBAAmB,EACnB,gCAAgC,EAChC,KAAK,WAAW,EAChB,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,GACvB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,qBAAqB,EACrB,mBAAmB,EACnB,gBAAgB,EAChB,cAAc,EACd,oBAAoB,GACrB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,eAAe,EACf,oBAAoB,EACpB,iBAAiB,EACjB,gBAAgB,EAChB,QAAQ,EACR,kBAAkB,EAClB,OAAO,EACP,aAAa,EACb,KAAK,wBAAwB,EAC7B,KAAK,gBAAgB,EACrB,KAAK,UAAU,EACf,KAAK,cAAc,GACpB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EACL,kBAAkB,EAClB,UAAU,EACV,gBAAgB,EAChB,SAAS,EACT,kBAAkB,EAClB,aAAa,EACb,iBAAiB,EACjB,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,YAAY,GAClB,MAAM,UAAU,CAAC"}
|
|
@@ -2,6 +2,7 @@ import { listRegisteredDeployChecks, setBuiltinCheckIds, toRunnerCheck } from '.
|
|
|
2
2
|
import { severityOf } from './types.js';
|
|
3
3
|
import { DATABASE_CHECKS } from './database.js';
|
|
4
4
|
import { DNS_CHECKS } from './dns.js';
|
|
5
|
+
import { COMPOSE_CHECKS } from './compose.js';
|
|
5
6
|
import { HOST_CHECKS } from './host.js';
|
|
6
7
|
import { SOURCE_CHECKS } from './source.js';
|
|
7
8
|
import { TLS_CHECKS } from './tls.js';
|
|
@@ -18,6 +19,8 @@ import { TLS_CHECKS } from './tls.js';
|
|
|
18
19
|
// with no docker should say so before it starts probing databases.
|
|
19
20
|
export const ALL_CHECKS = [
|
|
20
21
|
...HOST_CHECKS,
|
|
22
|
+
// After docker-daemon (in HOST_CHECKS), which both require.
|
|
23
|
+
...COMPOSE_CHECKS,
|
|
21
24
|
// After git-installed (in HOST_CHECKS), which gh-installed requires.
|
|
22
25
|
...SOURCE_CHECKS,
|
|
23
26
|
...DATABASE_CHECKS,
|
|
@@ -60,6 +63,7 @@ export function requiredChecks(checks = ALL_CHECKS, context) {
|
|
|
60
63
|
export * from './types.js';
|
|
61
64
|
export { freezeDeployCheckRegistry, listRegisteredDeployChecks, registerDeployCheck, resetDeployCheckRegistryForTests, } from './registry.js';
|
|
62
65
|
export { HOST_CHECKS, evaluateDf, probe } from './host.js';
|
|
66
|
+
export { COMPOSE_CHECKS } from './compose.js';
|
|
63
67
|
export { SOURCE_CHECKS, SOURCE_CHECK_IDS, gitCredentialStateFor, gitHasCredentialFor, isHttpsGithubUrl, needsGithubCli, nonInteractiveGitEnv, } from './source.js';
|
|
64
68
|
export { DATABASE_CHECKS, MAINTENANCE_DATABASE, canCreateDatabase, databaseSettings, probeTcp, readRoleAttributes, runPsql, runPsqlScript, } from './database.js';
|
|
65
69
|
export { DNS_CHECKS } from './dns.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/engine/deploy/checks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE9F,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEtC,gFAAgF;AAChF,8CAA8C;AAC9C,gFAAgF;AAChF,EAAE;AACF,+EAA+E;AAC/E,4EAA4E;AAC5E,6EAA6E;AAC7E,oCAAoC;AACpC,gFAAgF;AAEhF,2EAA2E;AAC3E,mEAAmE;AACnE,MAAM,CAAC,MAAM,UAAU,GAAqB;IAC1C,GAAG,WAAW;IACd,qEAAqE;IACrE,GAAG,aAAa;IAChB,GAAG,eAAe;IAClB,GAAG,UAAU;IACb,GAAG,UAAU;CACd,CAAC;AAEF,kBAAkB,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC;AAE9D;;;;GAIG;AACH,MAAM,UAAU,SAAS;IACvB,MAAM,UAAU,GAAG,0BAA0B,EAAE,CAAC;IAChD,OAAO,UAAU,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,GAAG,UA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SAAS,EAAE,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;AAC9C,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,cAAc,CAC5B,SAA2B,UAAU,EACrC,OAAsB;IAEtB,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAC7B,OAAO,KAAK,SAAS;QACnB,CAAC,CAAC,KAAK,CAAC,QAAQ,KAAK,UAAU;QAC/B,CAAC,CAAC,UAAU,CAAC,KAAK,EAAE,OAAO,CAAC,KAAK,UAAU,CAC9C,CAAC;AACJ,CAAC;AAED,cAAc,YAAY,CAAC;AAC3B,OAAO,EACL,yBAAyB,EACzB,0BAA0B,EAC1B,mBAAmB,EACnB,gCAAgC,GAIjC,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,qBAAqB,EACrB,mBAAmB,EACnB,gBAAgB,EAChB,cAAc,EACd,oBAAoB,GACrB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,eAAe,EACf,oBAAoB,EACpB,iBAAiB,EACjB,gBAAgB,EAChB,QAAQ,EACR,kBAAkB,EAClB,OAAO,EACP,aAAa,GAKd,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EACL,kBAAkB,EAClB,UAAU,EACV,gBAAgB,EAChB,SAAS,EACT,kBAAkB,EAClB,aAAa,EACb,iBAAiB,GAKlB,MAAM,UAAU,CAAC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The command seam detection runs through: the engine's `runCommand` (or a
|
|
3
|
+
* test's fake of it). Structural, so the executor's own function is assignable
|
|
4
|
+
* and nothing of the executor leaks into the public surface. It rejects when
|
|
5
|
+
* the command fails, which detection reads as "Docker cannot be asked".
|
|
6
|
+
*
|
|
7
|
+
* @stability experimental
|
|
8
|
+
*/
|
|
9
|
+
export type ComposeProjectCommandRunner = (argv: readonly string[], options: {
|
|
10
|
+
cwd: string;
|
|
11
|
+
timeoutMs?: number | undefined;
|
|
12
|
+
}) => Promise<{
|
|
13
|
+
/** What the command printed on stdout. */
|
|
14
|
+
stdout: string;
|
|
15
|
+
}>;
|
|
16
|
+
/**
|
|
17
|
+
* One container as the deploy checks and the detection see it.
|
|
18
|
+
*
|
|
19
|
+
* @stability experimental
|
|
20
|
+
*/
|
|
21
|
+
export interface ComposeContainer {
|
|
22
|
+
/** The container name, without Docker's leading slash. */
|
|
23
|
+
name: string;
|
|
24
|
+
/** Whether it is running now. */
|
|
25
|
+
running: boolean;
|
|
26
|
+
/** The host ports it is configured to publish (a range stays `8000-8010`); empty `HostPort`s are no claim and are not listed. */
|
|
27
|
+
hostPorts: string[];
|
|
28
|
+
/** Its `com.docker.compose.project` label, `''` when it is not a compose container. */
|
|
29
|
+
project: string;
|
|
30
|
+
/** Its `com.docker.compose.project.working_dir` label, `''` when absent. */
|
|
31
|
+
workingDir: string;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Whether `path` is `root` or inside it, by path segment: `/opt/apps/app2` is
|
|
35
|
+
* NOT under `/opt/apps/app`. Both are resolved first; nothing touches the disk,
|
|
36
|
+
* because a container's recorded directory need not exist any more.
|
|
37
|
+
*
|
|
38
|
+
* @param path - The path to test.
|
|
39
|
+
* @param root - The folder it may be under.
|
|
40
|
+
* @returns true when `path` is `root` or below it.
|
|
41
|
+
* @stability experimental
|
|
42
|
+
*/
|
|
43
|
+
export declare function isPathUnder(path: string, root: string): boolean;
|
|
44
|
+
/**
|
|
45
|
+
* The compose project a FRESH install of `deployRoot` gets: the folder name.
|
|
46
|
+
* An existing deployment keeps the one it runs under (`composeProjectFor`);
|
|
47
|
+
* only a deployment with no record and no evidence is named this way. Install
|
|
48
|
+
* and the `bind-port-owner` check both ask here, so they cannot disagree.
|
|
49
|
+
*
|
|
50
|
+
* @param deployRoot - The deployment folder.
|
|
51
|
+
* @returns the project name a fresh install would use.
|
|
52
|
+
*/
|
|
53
|
+
export declare function freshComposeProject(deployRoot: string): string;
|
|
54
|
+
/**
|
|
55
|
+
* Whether `container` is configured to publish host port `port`. An empty
|
|
56
|
+
* `HostPort` (Docker picks one) is no claim; a range claims every port in it.
|
|
57
|
+
*
|
|
58
|
+
* @param container - The container.
|
|
59
|
+
* @param port - The host port.
|
|
60
|
+
* @returns true when the container publishes it.
|
|
61
|
+
*/
|
|
62
|
+
export declare function publishesPort(container: Pick<ComposeContainer, 'hostPorts'>, port: number): boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Every container Docker knows, in any state, with its compose labels and the
|
|
65
|
+
* host ports it is configured to publish: one `docker ps -aq` and ONE
|
|
66
|
+
* `docker inspect`, argv only, never a shell string.
|
|
67
|
+
*
|
|
68
|
+
* @param run - The command seam; pass the engine's `runCommand`.
|
|
69
|
+
* @returns the containers, or `undefined` when Docker cannot be asked.
|
|
70
|
+
*/
|
|
71
|
+
export declare function listComposeContainers(run: ComposeProjectCommandRunner): Promise<ComposeContainer[] | undefined>;
|
|
72
|
+
//# sourceMappingURL=compose-containers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compose-containers.d.ts","sourceRoot":"","sources":["../../../src/engine/deploy/compose-containers.ts"],"names":[],"mappings":"AAuCA;;;;;;;GAOG;AACH,MAAM,MAAM,2BAA2B,GAAG,CACxC,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,OAAO,EAAE;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,KACrD,OAAO,CAAC;IACX,0CAA0C;IAC1C,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC,CAAC;AAEH;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC/B,0DAA0D;IAC1D,IAAI,EAAE,MAAM,CAAC;IACb,iCAAiC;IACjC,OAAO,EAAE,OAAO,CAAC;IACjB,iIAAiI;IACjI,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,uFAAuF;IACvF,OAAO,EAAE,MAAM,CAAC;IAChB,4EAA4E;IAC5E,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAG/D;AAED;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAE9D;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,SAAS,EAAE,IAAI,CAAC,gBAAgB,EAAE,WAAW,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAOnG;AAED;;;;;;;GAOG;AACH,wBAAsB,qBAAqB,CAAC,GAAG,EAAE,2BAA2B,GAAG,OAAO,CAAC,gBAAgB,EAAE,GAAG,SAAS,CAAC,CAyCrH"}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { basename, isAbsolute, relative, resolve, sep } from 'node:path';
|
|
2
|
+
// =============================================================================
|
|
3
|
+
// Which containers does Docker know, and which compose project is each in?
|
|
4
|
+
// =============================================================================
|
|
5
|
+
//
|
|
6
|
+
// The leaf under compose-project.ts (detection and reconciliation) and the
|
|
7
|
+
// `bind-port-owner` / `stray-compose-stack` deploy checks: it imports nothing
|
|
8
|
+
// from the engine, so a check can ask Docker without importing the install
|
|
9
|
+
// pipeline. Read-only (`docker ps`, `docker inspect`), argv only.
|
|
10
|
+
// =============================================================================
|
|
11
|
+
/** The label a container carries naming its compose project. */
|
|
12
|
+
const COMPOSE_PROJECT_LABEL = 'com.docker.compose.project';
|
|
13
|
+
/** The label naming the directory compose was run from. */
|
|
14
|
+
const COMPOSE_WORKING_DIR_LABEL = 'com.docker.compose.project.working_dir';
|
|
15
|
+
/** Short by design: a wedged Docker socket must cost seconds, not the command. */
|
|
16
|
+
const DOCKER_QUERY_TIMEOUT_MS = 10_000;
|
|
17
|
+
/**
|
|
18
|
+
* One line per container: name, running state, published host ports, compose
|
|
19
|
+
* project, then compose working directory.
|
|
20
|
+
*
|
|
21
|
+
* `{{if .Config.Labels}}` guards a container created without any labels, whose
|
|
22
|
+
* `Labels` is null rather than an empty map (`index` on nil renders
|
|
23
|
+
* `<no value>` into the line otherwise); the separators sit outside the guards
|
|
24
|
+
* so every line has all five fields. `PortBindings` is the CONFIGURED publish,
|
|
25
|
+
* present on a stopped or merely created container too, and a nil map ranges
|
|
26
|
+
* over nothing. The working directory comes last so a path containing the
|
|
27
|
+
* separator survives; none of the fields before it can contain one.
|
|
28
|
+
*/
|
|
29
|
+
const INSPECT_FORMAT = '{{.Name}}|{{.State.Running}}|' +
|
|
30
|
+
'{{range $port, $bindings := .HostConfig.PortBindings}}{{range $bindings}}{{.HostPort}},{{end}}{{end}}|' +
|
|
31
|
+
`{{if .Config.Labels}}{{index .Config.Labels "${COMPOSE_PROJECT_LABEL}"}}{{end}}|` +
|
|
32
|
+
`{{if .Config.Labels}}{{index .Config.Labels "${COMPOSE_WORKING_DIR_LABEL}"}}{{end}}`;
|
|
33
|
+
/**
|
|
34
|
+
* Whether `path` is `root` or inside it, by path segment: `/opt/apps/app2` is
|
|
35
|
+
* NOT under `/opt/apps/app`. Both are resolved first; nothing touches the disk,
|
|
36
|
+
* because a container's recorded directory need not exist any more.
|
|
37
|
+
*
|
|
38
|
+
* @param path - The path to test.
|
|
39
|
+
* @param root - The folder it may be under.
|
|
40
|
+
* @returns true when `path` is `root` or below it.
|
|
41
|
+
* @stability experimental
|
|
42
|
+
*/
|
|
43
|
+
export function isPathUnder(path, root) {
|
|
44
|
+
const relation = relative(resolve(root), resolve(path));
|
|
45
|
+
return relation === '' || (relation !== '..' && !relation.startsWith(`..${sep}`) && !isAbsolute(relation));
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* The compose project a FRESH install of `deployRoot` gets: the folder name.
|
|
49
|
+
* An existing deployment keeps the one it runs under (`composeProjectFor`);
|
|
50
|
+
* only a deployment with no record and no evidence is named this way. Install
|
|
51
|
+
* and the `bind-port-owner` check both ask here, so they cannot disagree.
|
|
52
|
+
*
|
|
53
|
+
* @param deployRoot - The deployment folder.
|
|
54
|
+
* @returns the project name a fresh install would use.
|
|
55
|
+
*/
|
|
56
|
+
export function freshComposeProject(deployRoot) {
|
|
57
|
+
return basename(deployRoot);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Whether `container` is configured to publish host port `port`. An empty
|
|
61
|
+
* `HostPort` (Docker picks one) is no claim; a range claims every port in it.
|
|
62
|
+
*
|
|
63
|
+
* @param container - The container.
|
|
64
|
+
* @param port - The host port.
|
|
65
|
+
* @returns true when the container publishes it.
|
|
66
|
+
*/
|
|
67
|
+
export function publishesPort(container, port) {
|
|
68
|
+
return container.hostPorts.some((entry) => {
|
|
69
|
+
const [first = '', last = first] = entry.split('-');
|
|
70
|
+
const low = Number(first);
|
|
71
|
+
const high = Number(last);
|
|
72
|
+
return Number.isInteger(low) && Number.isInteger(high) && low <= port && port <= high;
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Every container Docker knows, in any state, with its compose labels and the
|
|
77
|
+
* host ports it is configured to publish: one `docker ps -aq` and ONE
|
|
78
|
+
* `docker inspect`, argv only, never a shell string.
|
|
79
|
+
*
|
|
80
|
+
* @param run - The command seam; pass the engine's `runCommand`.
|
|
81
|
+
* @returns the containers, or `undefined` when Docker cannot be asked.
|
|
82
|
+
*/
|
|
83
|
+
export async function listComposeContainers(run) {
|
|
84
|
+
try {
|
|
85
|
+
const ask = (argv) => run(argv, { cwd: process.cwd(), timeoutMs: DOCKER_QUERY_TIMEOUT_MS });
|
|
86
|
+
// `-aq`: every container, whatever its state. Ids, which can never be ambiguous.
|
|
87
|
+
const ids = (await ask(['docker', 'ps', '-aq']))
|
|
88
|
+
.stdout.split('\n')
|
|
89
|
+
.map((line) => line.trim())
|
|
90
|
+
.filter((line) => line !== '');
|
|
91
|
+
if (ids.length === 0)
|
|
92
|
+
return [];
|
|
93
|
+
const { stdout } = await ask(['docker', 'inspect', '--format', INSPECT_FORMAT, ...ids]);
|
|
94
|
+
const containers = [];
|
|
95
|
+
for (const line of stdout.split('\n')) {
|
|
96
|
+
// Four separators, then the working directory (which may hold more). A
|
|
97
|
+
// line with fewer is not ours, such as the `<no value>` an unguarded
|
|
98
|
+
// template prints.
|
|
99
|
+
const fields = [];
|
|
100
|
+
let rest = line;
|
|
101
|
+
for (let index = 0; index < 4; index += 1) {
|
|
102
|
+
const separator = rest.indexOf('|');
|
|
103
|
+
if (separator === -1)
|
|
104
|
+
break;
|
|
105
|
+
fields.push(rest.slice(0, separator));
|
|
106
|
+
rest = rest.slice(separator + 1);
|
|
107
|
+
}
|
|
108
|
+
if (fields.length < 4)
|
|
109
|
+
continue;
|
|
110
|
+
const [name = '', running = '', ports = '', project = ''] = fields;
|
|
111
|
+
containers.push({
|
|
112
|
+
name: name.replace(/^\//, '').trim(),
|
|
113
|
+
running: running.trim() === 'true',
|
|
114
|
+
hostPorts: ports.split(',').map((port) => port.trim()).filter((port) => port !== ''),
|
|
115
|
+
project: project.trim(),
|
|
116
|
+
workingDir: rest.trim(),
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
return containers;
|
|
120
|
+
}
|
|
121
|
+
catch {
|
|
122
|
+
return undefined;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
//# sourceMappingURL=compose-containers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compose-containers.js","sourceRoot":"","sources":["../../../src/engine/deploy/compose-containers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,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-1,34 +1,35 @@
|
|
|
1
|
+
import { type ComposeProjectCommandRunner } from './compose-containers.js';
|
|
1
2
|
import { type DeployState } from './state.js';
|
|
3
|
+
export { isPathUnder, type ComposeContainer, type ComposeProjectCommandRunner } from './compose-containers.js';
|
|
2
4
|
/**
|
|
3
|
-
* The
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
5
|
+
* The evidence that decided which project a deployment folder runs under,
|
|
6
|
+
* strongest first. Lets a message say WHY a project was picked.
|
|
7
|
+
*
|
|
8
|
+
* - `bind-port`: a container of that project publishes the deployment's bind
|
|
9
|
+
* port (running ones first), which is the stack that serves the site.
|
|
10
|
+
* - `running`: it is the only project with a running container.
|
|
11
|
+
* - `only`: it is the only project with any container started from the folder.
|
|
7
12
|
*
|
|
8
13
|
* @stability experimental
|
|
9
14
|
*/
|
|
10
|
-
export type
|
|
11
|
-
cwd: string;
|
|
12
|
-
timeoutMs?: number | undefined;
|
|
13
|
-
}) => Promise<{
|
|
14
|
-
/** What the command printed on stdout. */
|
|
15
|
-
stdout: string;
|
|
16
|
-
}>;
|
|
15
|
+
export type ComposeProjectBasis = 'bind-port' | 'running' | 'only';
|
|
17
16
|
/**
|
|
18
17
|
* What Docker says about the compose project of a deployment folder.
|
|
19
18
|
*
|
|
20
19
|
* @stability experimental
|
|
21
20
|
*/
|
|
22
21
|
export type ComposeProjectDetection = {
|
|
23
|
-
/**
|
|
22
|
+
/** One project is decided by the strongest evidence among those started from inside the folder. */
|
|
24
23
|
kind: 'found';
|
|
25
24
|
/** That project's name. */
|
|
26
25
|
project: string;
|
|
26
|
+
/** The evidence that decided it. */
|
|
27
|
+
basis: ComposeProjectBasis;
|
|
27
28
|
} | {
|
|
28
29
|
/** No container was started from inside the folder. */
|
|
29
30
|
kind: 'none';
|
|
30
31
|
} | {
|
|
31
|
-
/** Several projects own containers started from inside the folder. */
|
|
32
|
+
/** Several projects own containers started from inside the folder and no evidence separates them. */
|
|
32
33
|
kind: 'ambiguous';
|
|
33
34
|
/** Their names, sorted. */
|
|
34
35
|
projects: string[];
|
|
@@ -37,30 +38,29 @@ export type ComposeProjectDetection = {
|
|
|
37
38
|
kind: 'unavailable';
|
|
38
39
|
};
|
|
39
40
|
/**
|
|
40
|
-
*
|
|
41
|
-
* NOT under `/opt/apps/app`. Both are resolved first; nothing touches the disk,
|
|
42
|
-
* because a container's recorded directory need not exist any more.
|
|
43
|
-
*
|
|
44
|
-
* @param path - The path to test.
|
|
45
|
-
* @param root - The folder it may be under.
|
|
46
|
-
* @returns true when `path` is `root` or below it.
|
|
47
|
-
* @stability experimental
|
|
48
|
-
*/
|
|
49
|
-
export declare function isPathUnder(path: string, root: string): boolean;
|
|
50
|
-
/**
|
|
51
|
-
* Asks Docker which compose project(s) the containers started from inside
|
|
41
|
+
* Asks Docker which compose project the containers started from inside
|
|
52
42
|
* `deployRoot` belong to, stopped containers included. A container is the
|
|
53
43
|
* deployment's when its working-directory label is the deploy root or under it.
|
|
54
44
|
*
|
|
45
|
+
* Several projects can live in one folder (the live stack plus leftovers of
|
|
46
|
+
* another), so the answer is the project the STRONGEST evidence names, in
|
|
47
|
+
* order: (1) the project of a container that publishes `options.bindPort`
|
|
48
|
+
* (running ones first: a stopped leftover publishes it in its configuration
|
|
49
|
+
* too), (2) the only project with a running container, (3) the only project.
|
|
50
|
+
* Several projects and no evidence that separates them is `ambiguous`.
|
|
51
|
+
*
|
|
55
52
|
* Never throws: a Docker that cannot be asked is `unavailable`. Read-only
|
|
56
53
|
* (`docker ps`, `docker inspect`), and argv only, never a shell string.
|
|
57
54
|
*
|
|
58
55
|
* @param deployRoot - The deployment folder (`<apps-root>/<name>`).
|
|
59
56
|
* @param run - The command seam; pass the engine's `runCommand`.
|
|
60
|
-
* @
|
|
57
|
+
* @param options - `bindPort`: the deployment's loopback port, the strongest evidence when known.
|
|
58
|
+
* @returns the project found and why, none, several, or unavailable.
|
|
61
59
|
* @stability experimental
|
|
62
60
|
*/
|
|
63
|
-
export declare function detectComposeProject(deployRoot: string, run: ComposeProjectCommandRunner
|
|
61
|
+
export declare function detectComposeProject(deployRoot: string, run: ComposeProjectCommandRunner, options?: {
|
|
62
|
+
bindPort?: number | undefined;
|
|
63
|
+
}): Promise<ComposeProjectDetection>;
|
|
64
64
|
/** What `reconcileComposeProject` needs. */
|
|
65
65
|
export interface ReconcileComposeProjectOptions {
|
|
66
66
|
/** The deployment folder. */
|
|
@@ -81,12 +81,18 @@ export interface ReconcileComposeProjectResult {
|
|
|
81
81
|
* Makes the carried compose project match the one Docker says the deployment
|
|
82
82
|
* runs under, when the record is absent or the legacy default.
|
|
83
83
|
*
|
|
84
|
+
* Docker names the project by the strongest evidence (see
|
|
85
|
+
* `detectComposeProject`), the state's bind port first: the stack that holds
|
|
86
|
+
* the port is the one that serves, whatever leftovers share the folder.
|
|
87
|
+
*
|
|
84
88
|
* Changes nothing (the state comes back as given) when there is no state, when
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
89
|
+
* Docker cannot be asked or knows no container of this folder, or when it
|
|
90
|
+
* already agrees. A project recorded on purpose is never overwritten; when the
|
|
91
|
+
* container holding the bind port belongs to ANOTHER project it is only
|
|
92
|
+
* reported (a warning), and the `bind-port-owner` check fails the run before
|
|
93
|
+
* anything starts. An ambiguous answer, with nothing decisive, changes nothing
|
|
94
|
+
* and returns a warning naming the projects and the state file: it is never
|
|
95
|
+
* silent, because keeping `compose` unseen is how a second stack got started.
|
|
90
96
|
*
|
|
91
97
|
* On `found` with a different project: the returned state carries it, and when
|
|
92
98
|
* a state file is on disk it is rewritten through the engine's own writer (same
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compose-project.d.ts","sourceRoot":"","sources":["../../../src/engine/deploy/compose-project.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"compose-project.d.ts","sourceRoot":"","sources":["../../../src/engine/deploy/compose-project.ts"],"names":[],"mappings":"AAGA,OA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