@tahminator/pipeline 1.0.102 → 1.0.103-beta.g897680a4
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/docker/client.d.ts +5 -0
- package/dist/docker/client.js +9 -2
- package/dist/env/strategy/sops.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -447,6 +447,8 @@ await client.buildImage({
|
|
|
447
447
|
tags: ["latest", "sha-abc123"], // define as many as you would like
|
|
448
448
|
platforms: ["linux/amd64", "linux/arm64"], // build for multiple platforms
|
|
449
449
|
buildArgs: { NODE_ENV: "production" }, // pass in build args
|
|
450
|
+
// read in the Dockerfile with `RUN --mount=type=secret,id=NPM_TOKEN`
|
|
451
|
+
secrets: { NPM_TOKEN: process.env.NPM_TOKEN! },
|
|
450
452
|
});
|
|
451
453
|
|
|
452
454
|
await client.buildImage({
|
package/dist/docker/client.d.ts
CHANGED
|
@@ -35,6 +35,11 @@ export declare class DockerClient {
|
|
|
35
35
|
shouldUpload?: boolean;
|
|
36
36
|
platforms?: string[];
|
|
37
37
|
buildArgs?: Record<string, string | number | boolean>;
|
|
38
|
+
/**
|
|
39
|
+
* BuildKit secrets keyed by id, readable in the Dockerfile via `RUN --mount=type=secret,id=<id>`.
|
|
40
|
+
* Values are handed to `docker buildx build` through environment variables, so they never reach argv or disk.
|
|
41
|
+
*/
|
|
42
|
+
secrets?: Record<string, string>;
|
|
38
43
|
}): Promise<void>;
|
|
39
44
|
[Symbol.asyncDispose](): Promise<void>;
|
|
40
45
|
cleanup(): Promise<void>;
|
package/dist/docker/client.js
CHANGED
|
@@ -41,7 +41,7 @@ export class DockerClient {
|
|
|
41
41
|
console.log(`Promoted ${originalTag} to: ${newGithubTags.join(", ")}`);
|
|
42
42
|
}
|
|
43
43
|
async buildImage(args) {
|
|
44
|
-
const { dockerFileLocation, tags, dockerRepository, shouldUpload = true, platforms = ["linux/amd64"], buildArgs = {}, } = args;
|
|
44
|
+
const { dockerFileLocation, tags, dockerRepository, shouldUpload = true, platforms = ["linux/amd64"], buildArgs = {}, secrets = {}, } = args;
|
|
45
45
|
if (!tags.length) {
|
|
46
46
|
throw new Error("You must provide atleast one tag.");
|
|
47
47
|
}
|
|
@@ -65,16 +65,23 @@ export class DockerClient {
|
|
|
65
65
|
"--build-arg",
|
|
66
66
|
`${k}=${v.toString()}`,
|
|
67
67
|
]);
|
|
68
|
+
const secretEnv = {};
|
|
69
|
+
const secretFlags = Object.entries(secrets).flatMap(([id, value], i) => {
|
|
70
|
+
const envName = `PIPELINE_DOCKER_BUILD_SECRET_${i}`;
|
|
71
|
+
secretEnv[envName] = value;
|
|
72
|
+
return ["--secret", `id=${id},env=${envName}`];
|
|
73
|
+
});
|
|
68
74
|
await $ `docker buildx build ${buildModeFlag} \
|
|
69
75
|
--platform ${platforms.join(",")} \
|
|
70
76
|
--file ${dockerFileLocation} \
|
|
71
77
|
--cache-from=type=gha \
|
|
72
78
|
--cache-to=type=gha,mode=max \
|
|
73
79
|
${buildArgFlags} \
|
|
80
|
+
${secretFlags} \
|
|
74
81
|
--network host \
|
|
75
82
|
--allow network.host \
|
|
76
83
|
${tagFlags} \
|
|
77
|
-
|
|
84
|
+
.`.env({ ...process.env, ...secretEnv });
|
|
78
85
|
console.log(shouldUpload
|
|
79
86
|
? `Image build & successfully uploaded to ${this.username}/${dockerRepository}`
|
|
80
87
|
: "Image has been built (upload skipped.)");
|
|
@@ -26,7 +26,7 @@ export class SopsEnvClientStrategy {
|
|
|
26
26
|
}
|
|
27
27
|
console.log(`Loading ${envFile.name}`);
|
|
28
28
|
const content = await $ `sops decrypt ${path}`.text();
|
|
29
|
-
const parsed = yaml.parse(content);
|
|
29
|
+
const parsed = yaml.parse(content, { intAsBigInt: true });
|
|
30
30
|
if (!parsed || Array.isArray(parsed)) {
|
|
31
31
|
throw new Error(`Expected ${envFile.name} to decrypt to a root-level YAML object.`);
|
|
32
32
|
}
|
package/package.json
CHANGED