@mastra/docker 0.9.3 → 0.9.4-alpha.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 +2 -0
- package/dist/index.cjs +21 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +21 -6
- package/dist/index.js.map +1 -1
- package/dist/template/dockerfile.d.ts +7 -0
- package/dist/template/dockerfile.d.ts.map +1 -1
- package/dist/template/repo-template.d.ts +7 -0
- package/dist/template/repo-template.d.ts.map +1 -1
- package/dist/template/template.d.ts.map +1 -1
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -1575,6 +1575,11 @@ function renderSecretRun(command, secrets) {
|
|
|
1575
1575
|
const prefix = names.length > 0 ? [`export ${exports.join(" ")}`] : [];
|
|
1576
1576
|
return `RUN ${[...mounts, ""].join(" ")}${[...prefix, ...toCommandList(command)].join(" && ")}`;
|
|
1577
1577
|
}
|
|
1578
|
+
const OWNER_PATTERN = /^[A-Za-z0-9_.-]+(:[A-Za-z0-9_.-]+)?$/;
|
|
1579
|
+
/** Throws unless `owner` is a `user[:group]` or `uid[:gid]` usable in `COPY --chown`. */
|
|
1580
|
+
function assertValidOwner(owner) {
|
|
1581
|
+
if (typeof owner !== "string" || !OWNER_PATTERN.test(owner)) throw new TypeError(`owner must be user[:group] or uid[:gid], got ${JSON.stringify(owner)}`);
|
|
1582
|
+
}
|
|
1578
1583
|
function synthesizeDockerfile(definition) {
|
|
1579
1584
|
const lines = [];
|
|
1580
1585
|
let mainIndex = 0;
|
|
@@ -1596,13 +1601,14 @@ function synthesizeDockerfile(definition) {
|
|
|
1596
1601
|
lines.push(`RUN ${toCommandList(operation.args[0]).join(" && ")}`);
|
|
1597
1602
|
break;
|
|
1598
1603
|
case "runWithSecrets": {
|
|
1599
|
-
const [command, { secrets, output }] = operation.args;
|
|
1604
|
+
const [command, { secrets, output, owner }] = operation.args;
|
|
1605
|
+
if (owner !== void 0) assertValidOwner(owner);
|
|
1600
1606
|
const snapshot = mainStageName(mainIndex);
|
|
1601
1607
|
const stage = secretStageName(index);
|
|
1602
1608
|
lines.push(`FROM ${snapshot} AS ${stage}`, renderSecretRun(command, secrets));
|
|
1603
1609
|
mainIndex += 1;
|
|
1604
1610
|
openMain(snapshot);
|
|
1605
|
-
lines.push(`COPY --from=${stage} ${output} ${output}`);
|
|
1611
|
+
lines.push(`COPY ${owner !== void 0 ? `--chown=${owner} ` : ""}--from=${stage} ${output} ${output}`);
|
|
1606
1612
|
break;
|
|
1607
1613
|
}
|
|
1608
1614
|
case "aptInstall":
|
|
@@ -1633,12 +1639,13 @@ function canonicalOperation(operation) {
|
|
|
1633
1639
|
args: [sortedEntries(operation.args[0])]
|
|
1634
1640
|
};
|
|
1635
1641
|
case "runWithSecrets": {
|
|
1636
|
-
const [command, { secrets, output }] = operation.args;
|
|
1642
|
+
const [command, { secrets, output, owner }] = operation.args;
|
|
1637
1643
|
return {
|
|
1638
1644
|
method: "runWithSecrets",
|
|
1639
1645
|
args: [command, {
|
|
1640
1646
|
secrets: [...secrets].sort(),
|
|
1641
|
-
output
|
|
1647
|
+
output,
|
|
1648
|
+
...owner !== void 0 ? { owner } : {}
|
|
1642
1649
|
}]
|
|
1643
1650
|
};
|
|
1644
1651
|
}
|
|
@@ -1784,11 +1791,17 @@ var DockerTemplate = class DockerTemplate {
|
|
|
1784
1791
|
});
|
|
1785
1792
|
const output = validateString(options.output, "output");
|
|
1786
1793
|
if (!output.startsWith("/")) throw new TypeError("output must be an absolute path");
|
|
1794
|
+
let owner;
|
|
1795
|
+
if (options.owner !== void 0) {
|
|
1796
|
+
owner = validateString(options.owner, "owner");
|
|
1797
|
+
assertValidOwner(owner);
|
|
1798
|
+
}
|
|
1787
1799
|
return this.#append({
|
|
1788
1800
|
method: "runWithSecrets",
|
|
1789
1801
|
args: [validateStringOrStrings(command, "command"), {
|
|
1790
1802
|
secrets,
|
|
1791
|
-
output
|
|
1803
|
+
output,
|
|
1804
|
+
...owner !== void 0 ? { owner } : {}
|
|
1792
1805
|
}]
|
|
1793
1806
|
});
|
|
1794
1807
|
}
|
|
@@ -2239,6 +2252,7 @@ async function resolveRepoTemplate(options, workingDirectory, resolveOptions = {
|
|
|
2239
2252
|
setupCommand: options.setupCommand,
|
|
2240
2253
|
workingDirectory,
|
|
2241
2254
|
baseImage: options.baseImage,
|
|
2255
|
+
owner: options.owner,
|
|
2242
2256
|
dockerOptions: options.dockerOptions
|
|
2243
2257
|
});
|
|
2244
2258
|
}
|
|
@@ -2265,7 +2279,8 @@ function buildRepoTemplate(inputs) {
|
|
|
2265
2279
|
}), `git -C ${shellQuote(destination)} checkout --detach ${shellQuote(sha)}`];
|
|
2266
2280
|
template = template.runWithSecrets(clone, {
|
|
2267
2281
|
secrets: tokenEnv ? [tokenEnv] : [],
|
|
2268
|
-
output: destination
|
|
2282
|
+
output: destination,
|
|
2283
|
+
...inputs.owner !== void 0 ? { owner: inputs.owner } : {}
|
|
2269
2284
|
}).setWorkdir(destination);
|
|
2270
2285
|
const setupCommands = normalizeSetupCommands(inputs.setupCommand);
|
|
2271
2286
|
for (const command of setupCommands) template = template.runCmd(command);
|