openship 0.4.7 → 0.5.0
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/README.md +1 -0
- package/dist/{bare-2HYDXQEH.js → bare-VRGE5MXH.js} +7 -7
- package/dist/{chunk-TGIINPVM.js → chunk-6LKHXB6T.js} +22 -7
- package/dist/{chunk-R5BHFFAV.js → chunk-6PIYRG5I.js} +56 -17
- package/dist/{chunk-IMBD5PZ5.js → chunk-BS2AXYZX.js} +430 -86
- package/dist/{chunk-SJIFLLX4.js → chunk-CUJXGK7R.js} +321 -85
- package/dist/{chunk-VFINNTUL.js → chunk-EAAGSQXN.js} +23 -8
- package/dist/{chunk-4Z5QO7N6.js → chunk-I6PSTQIR.js} +2 -2
- package/dist/{chunk-XFCDYZUQ.js → chunk-JLKKYUZA.js} +31 -49
- package/dist/{chunk-4TJC4JZQ.js → chunk-K2RPVGPN.js} +23 -4
- package/dist/{chunk-MZ2WEHHY.js → chunk-KNTJ7PSF.js} +1 -1
- package/dist/{chunk-L2VOGB2X.js → chunk-KZOBYJUW.js} +1 -1
- package/dist/{chunk-IPYPMI3S.js → chunk-NNPEG6HM.js} +1 -1
- package/dist/{chunk-UXWAVM4C.js → chunk-NXFIRK2Z.js} +398 -112
- package/dist/{chunk-FXTBHTWY.js → chunk-RB35YN3J.js} +271 -35
- package/dist/{chunk-6APULWSU.js → chunk-UMQP7SYT.js} +429 -66
- package/dist/{chunk-V6AN6XLZ.js → chunk-V7BZMGOT.js} +123 -45
- package/dist/{chunk-VDMQJHPI.js → chunk-YWMODKWL.js} +67 -4
- package/dist/{chunk-OXWDY22G.js → chunk-ZCOQJCZO.js} +1 -1
- package/dist/{cloud-2KXREXMO.js → cloud-3M2WZ624.js} +12 -12
- package/dist/{detect-2XSCFFTF.js → detect-BAJMY6KM.js} +7 -5
- package/dist/{docker-LODK5Y2S.js → docker-2NGBRJFJ.js} +9 -7
- package/dist/{docker-edge-executor-VHW3JPJS.js → docker-edge-executor-5I4M5QT7.js} +1 -1
- package/dist/{edge-import-ZQ4Y5HEA.js → edge-import-RIWNEIXQ.js} +21 -19
- package/dist/{ensure-container-edge-ED25XL3Z.js → ensure-container-edge-3NSYKHRX.js} +6 -6
- package/dist/{executor-YPT6RH6O.js → executor-LOYMPU67.js} +3 -3
- package/dist/index.js +309 -338
- package/dist/{nginx-XWJAOGS4.js → nginx-QE4DOM5J.js} +4 -4
- package/dist/{openresty-lua-4WLGDSER.js → openresty-lua-BTAKECCF.js} +2 -2
- package/dist/server/index.js +51705 -45369
- package/dist/server/migrations/0073_project_volumes_object_storage.sql +3 -0
- package/dist/server/migrations/0074_project_compose_path.sql +1 -0
- package/dist/server/migrations/0075_service_command_argv.sql +1 -0
- package/dist/server/migrations/0076_rollback_retention.sql +17 -0
- package/dist/server/migrations/0077_domain_redirect.sql +13 -0
- package/dist/server/migrations/0078_grant_source_scope.sql +30 -0
- package/dist/server/migrations/0079_project_readiness.sql +18 -0
- package/dist/server/migrations/0080_deployment_error_classification.sql +26 -0
- package/dist/server/migrations/0081_project_readiness_repair.sql +34 -0
- package/dist/server/migrations/meta/_journal.json +63 -0
- package/dist/{setup-2DMFIA74.js → setup-KELALK7H.js} +7 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
<a href="docs/i18n/README.pt.md"><img src="https://img.shields.io/badge/lang-Português-555" alt="Português" /></a>
|
|
36
36
|
<a href="docs/i18n/README.de.md"><img src="https://img.shields.io/badge/lang-Deutsch-555" alt="Deutsch" /></a>
|
|
37
37
|
<a href="docs/i18n/README.tr.md"><img src="https://img.shields.io/badge/lang-Türkçe-555" alt="Türkçe" /></a>
|
|
38
|
+
<a href="docs/i18n/README.ko.md"><img src="https://img.shields.io/badge/lang-한국어-555" alt="한국어" /></a>
|
|
38
39
|
</p>
|
|
39
40
|
|
|
40
41
|
<p align="center">
|
|
@@ -5,17 +5,17 @@ const require = __ospCreateRequire(import.meta.url);
|
|
|
5
5
|
import {
|
|
6
6
|
BareRuntime,
|
|
7
7
|
STATIC_RELEASE_BASE
|
|
8
|
-
} from "./chunk-
|
|
9
|
-
import "./chunk-
|
|
10
|
-
import "./chunk-
|
|
11
|
-
import "./chunk-
|
|
12
|
-
import "./chunk-
|
|
13
|
-
import "./chunk-
|
|
8
|
+
} from "./chunk-YWMODKWL.js";
|
|
9
|
+
import "./chunk-KNTJ7PSF.js";
|
|
10
|
+
import "./chunk-KZOBYJUW.js";
|
|
11
|
+
import "./chunk-I6PSTQIR.js";
|
|
12
|
+
import "./chunk-K2RPVGPN.js";
|
|
13
|
+
import "./chunk-ZCOQJCZO.js";
|
|
14
14
|
import "./chunk-RPHRPFEH.js";
|
|
15
15
|
import "./chunk-TYVME3XD.js";
|
|
16
16
|
import "./chunk-FPRHYBY2.js";
|
|
17
17
|
import "./chunk-ILFETZOM.js";
|
|
18
|
-
import "./chunk-
|
|
18
|
+
import "./chunk-UMQP7SYT.js";
|
|
19
19
|
import "./chunk-KI2EY3WB.js";
|
|
20
20
|
export {
|
|
21
21
|
BareRuntime,
|
|
@@ -14,6 +14,15 @@ import {
|
|
|
14
14
|
import Dockerode from "dockerode";
|
|
15
15
|
import { PassThrough } from "stream";
|
|
16
16
|
var DEFAULT_SOCKET = "/var/run/docker.sock";
|
|
17
|
+
function explainEdgeExecError(err, containerName) {
|
|
18
|
+
const msg = err?.message ?? String(err);
|
|
19
|
+
if (/is not running|not running|409/i.test(msg)) {
|
|
20
|
+
return new Error(
|
|
21
|
+
`edge container "${containerName}" is not running yet (still starting, or stopped) \u2014 wait for it to be up (docker start ${containerName}) and retry.`
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
return err instanceof Error ? err : new Error(msg);
|
|
25
|
+
}
|
|
17
26
|
var WRITE_CHUNK = 6e4;
|
|
18
27
|
var DockerEdgeExecutor = class {
|
|
19
28
|
docker;
|
|
@@ -30,13 +39,19 @@ var DockerEdgeExecutor = class {
|
|
|
30
39
|
/** Run one command inside the edge container, capturing stdout/stderr + exit. */
|
|
31
40
|
async run(command) {
|
|
32
41
|
const container = this.docker.getContainer(this.containerName);
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
42
|
+
let exec;
|
|
43
|
+
let stream;
|
|
44
|
+
try {
|
|
45
|
+
exec = await container.exec({
|
|
46
|
+
Cmd: ["/bin/sh", "-c", command],
|
|
47
|
+
AttachStdout: true,
|
|
48
|
+
AttachStderr: true,
|
|
49
|
+
Tty: false
|
|
50
|
+
});
|
|
51
|
+
stream = await exec.start({ stdin: false });
|
|
52
|
+
} catch (err) {
|
|
53
|
+
throw explainEdgeExecError(err, this.containerName);
|
|
54
|
+
}
|
|
40
55
|
const outStream = new PassThrough();
|
|
41
56
|
const errStream = new PassThrough();
|
|
42
57
|
let stdout = "";
|
|
@@ -8,10 +8,10 @@ import {
|
|
|
8
8
|
} from "./chunk-ILFETZOM.js";
|
|
9
9
|
import {
|
|
10
10
|
OPENRESTY_LUA_DIR
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-EAAGSQXN.js";
|
|
12
12
|
import {
|
|
13
13
|
AppError
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-UMQP7SYT.js";
|
|
15
15
|
|
|
16
16
|
// ../../packages/adapters/src/system/proxy/detect.ts
|
|
17
17
|
var EDGE_PORTS = [80, 443];
|
|
@@ -59,21 +59,59 @@ function sq(value) {
|
|
|
59
59
|
function isOurEdgeContainer(name, image) {
|
|
60
60
|
return /openship-edge/i.test(`${name ?? ""} ${image ?? ""}`);
|
|
61
61
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
62
|
+
function vhostLog(message, level = "info") {
|
|
63
|
+
return { timestamp: (/* @__PURE__ */ new Date()).toISOString(), message, level };
|
|
64
|
+
}
|
|
65
|
+
async function sanitizeEdgeVhosts(executor, sitesDir, onLog) {
|
|
66
|
+
const script = [
|
|
67
|
+
`for f in ${sq(sitesDir)}/*.conf; do`,
|
|
68
|
+
// A host-side vhost may be a symlink into /etc/nginx/sites-available. That
|
|
69
|
+
// target is deliberately not mounted in the edge container, so leaving the
|
|
70
|
+
// link here makes nginx's include glob fail at startup. Materialize valid
|
|
71
|
+
// links before the container mounts this directory; remove dangling ones.
|
|
72
|
+
` [ -e "$f" ] || [ -L "$f" ] || continue;`,
|
|
73
|
+
` if [ -L "$f" ]; then`,
|
|
74
|
+
` if [ ! -e "$f" ]; then`,
|
|
75
|
+
` echo "dropped-dangling-link $f"; rm -f "$f"; continue;`,
|
|
76
|
+
` fi;`,
|
|
77
|
+
` if cat "$f" > "$f.osh-link"; then`,
|
|
78
|
+
` rm -f "$f"; mv "$f.osh-link" "$f"; echo "materialized-link $f";`,
|
|
79
|
+
` else`,
|
|
80
|
+
` rm -f "$f.osh-link"; echo "dropped-unreadable-link $f"; rm -f "$f"; continue;`,
|
|
81
|
+
` fi;`,
|
|
82
|
+
` fi;`,
|
|
83
|
+
// A real server_name is anything that isn't the `_` wildcard.
|
|
84
|
+
` if ! grep -qE '^[[:space:]]*server_name[[:space:]]+[^_;[:space:]]' "$f"; then`,
|
|
85
|
+
` echo "dropped-catchall $f"; rm -f "$f"; continue;`,
|
|
86
|
+
` fi;`,
|
|
87
|
+
` if grep -qE '[[:space:]]default_server' "$f"; then`,
|
|
88
|
+
` sed -E 's/([[:space:]]listen[^;]*)[[:space:]]+default_server/\\1/g' "$f" > "$f.osh" && mv "$f.osh" "$f" && echo "unset-default $f";`,
|
|
89
|
+
` fi;`,
|
|
90
|
+
`done`
|
|
91
|
+
].join(" ");
|
|
92
|
+
const out = await executor.exec(script).catch(() => "");
|
|
93
|
+
for (const line of out.split("\n").map((l) => l.trim()).filter(Boolean)) {
|
|
94
|
+
const [action, file] = [line.slice(0, line.indexOf(" ")), line.slice(line.indexOf(" ") + 1)];
|
|
95
|
+
if (action === "dropped-catchall") {
|
|
96
|
+
onLog(vhostLog(`Dropped catch-all vhost ${file} \u2014 the edge image provides it.`, "warn"));
|
|
97
|
+
} else if (action === "unset-default") {
|
|
98
|
+
onLog(vhostLog(`Removed default_server from ${file} \u2014 the edge image owns it.`, "warn"));
|
|
99
|
+
} else if (action === "materialized-link") {
|
|
100
|
+
onLog(vhostLog(`Materialized linked edge vhost ${file} for the container mount.`, "warn"));
|
|
101
|
+
} else if (action === "dropped-dangling-link") {
|
|
102
|
+
onLog(vhostLog(`Dropped dangling edge vhost link ${file}.`, "warn"));
|
|
103
|
+
} else if (action === "dropped-unreadable-link") {
|
|
104
|
+
onLog(vhostLog(`Dropped unreadable edge vhost link ${file}.`, "warn"));
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
async function edgeIsBroken(executor) {
|
|
109
|
+
const status = await tryExec(
|
|
69
110
|
executor,
|
|
70
|
-
|
|
111
|
+
`docker inspect -f '{{.State.Status}}' ${sq(EDGE_CONTAINER_NAME)} 2>/dev/null`
|
|
71
112
|
);
|
|
72
|
-
const
|
|
73
|
-
return
|
|
74
|
-
}
|
|
75
|
-
function containerShell(command) {
|
|
76
|
-
return `docker exec ${sq(EDGE_CONTAINER_NAME)} sh -c ${sq(command)}`;
|
|
113
|
+
const state = (status ?? "").trim();
|
|
114
|
+
return state === "restarting" || state === "exited" || state === "dead";
|
|
77
115
|
}
|
|
78
116
|
async function edgeCrashReason(executor) {
|
|
79
117
|
const logs = await tryExec(
|
|
@@ -86,7 +124,7 @@ function edgeFailureReason(containerLog) {
|
|
|
86
124
|
const lines = containerLog.split("\n").map((l) => l.trim()).filter(Boolean);
|
|
87
125
|
const emerg = lines.find((l) => l.includes("[emerg]"));
|
|
88
126
|
if (emerg) return emerg.replace(/^.*\[emerg\]\s*\d*#\d*:\s*/, "");
|
|
89
|
-
return
|
|
127
|
+
return null;
|
|
90
128
|
}
|
|
91
129
|
var EDGE_CONTAINER_NAME = "openship-edge";
|
|
92
130
|
async function ourEdgeContainerRunning(executor) {
|
|
@@ -268,7 +306,8 @@ export {
|
|
|
268
306
|
classifyProxy,
|
|
269
307
|
sq,
|
|
270
308
|
isOurEdgeContainer,
|
|
271
|
-
|
|
309
|
+
sanitizeEdgeVhosts,
|
|
310
|
+
edgeIsBroken,
|
|
272
311
|
edgeCrashReason,
|
|
273
312
|
edgeFailureReason,
|
|
274
313
|
EDGE_CONTAINER_NAME,
|