@catladder/pipeline 3.31.0 → 3.32.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/dist/build/docker.d.ts +1 -1
- package/dist/build/docker.js +16 -4
- package/dist/build/types.d.ts +9 -0
- package/dist/constants.js +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/examples/__snapshots__/custom-docker-file.test.ts.snap +1640 -0
- package/examples/custom-docker-file.test.ts +12 -0
- package/examples/custom-docker-file.ts +36 -0
- package/package.json +1 -1
- package/src/build/docker.ts +26 -6
- package/src/build/types.ts +10 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { it, expect } from "vitest";
|
|
2
|
+
import { createYamlLocalPipeline } from "./__utils__/helpers";
|
|
3
|
+
import config from "./custom-docker-file";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* This test is auto-generated.
|
|
7
|
+
* Modifications will be overwritten on every `yarn test` run!
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
it("matches snapshot for custom-docker-file local pipeline YAML", async () => {
|
|
11
|
+
expect(await createYamlLocalPipeline(config)).toMatchSnapshot();
|
|
12
|
+
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { Config } from "../src";
|
|
2
|
+
|
|
3
|
+
const config = {
|
|
4
|
+
appName: "test-app",
|
|
5
|
+
customerName: "pan",
|
|
6
|
+
components: {
|
|
7
|
+
www: {
|
|
8
|
+
dir: "www",
|
|
9
|
+
build: {
|
|
10
|
+
type: "node",
|
|
11
|
+
jobImage: "foo",
|
|
12
|
+
docker: {
|
|
13
|
+
type: "custom",
|
|
14
|
+
dockerfileContent: [
|
|
15
|
+
"FROM node:22",
|
|
16
|
+
"USER node",
|
|
17
|
+
"$DOCKER_COPY_WORKSPACE_FILES",
|
|
18
|
+
"WORKDIR /app/$APP_DIR",
|
|
19
|
+
"$DOCKER_COPY_AND_INSTALL_APP",
|
|
20
|
+
],
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
deploy: {
|
|
24
|
+
type: "google-cloudrun",
|
|
25
|
+
projectId: "asdf",
|
|
26
|
+
region: "asia-east1",
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
} satisfies Config;
|
|
31
|
+
|
|
32
|
+
export default config;
|
|
33
|
+
|
|
34
|
+
export const information = {
|
|
35
|
+
title: "Custom Dockerfile",
|
|
36
|
+
};
|
package/package.json
CHANGED
package/src/build/docker.ts
CHANGED
|
@@ -166,19 +166,39 @@ const BUILT_IN_ENSURE_DOCKERFILE_SCRIPTS = {
|
|
|
166
166
|
[type in BuildConfigDocker["type"]]: string | null;
|
|
167
167
|
};
|
|
168
168
|
|
|
169
|
-
|
|
169
|
+
const getEnsureDockerFileScript = (
|
|
170
170
|
context: ComponentContextWithBuild,
|
|
171
|
-
|
|
171
|
+
fallbackType?: BuildConfigDocker["type"],
|
|
172
172
|
) => {
|
|
173
|
-
|
|
173
|
+
if (
|
|
174
174
|
"docker" in context.build.config &&
|
|
175
175
|
context.build.config.docker &&
|
|
176
176
|
"type" in context.build.config.docker
|
|
177
|
-
|
|
178
|
-
|
|
177
|
+
) {
|
|
178
|
+
if (context.build.config.docker?.type === "custom") {
|
|
179
|
+
if (context.build.config.docker?.dockerfileContent) {
|
|
180
|
+
// we need to create a script that creates a Dockerfile in the current directory
|
|
181
|
+
return `
|
|
182
|
+
echo "Creating Dockerfile"
|
|
183
|
+
cat >$APP_DIR/Dockerfile <<EOF
|
|
184
|
+
${context.build.config.docker?.dockerfileContent?.join("\n")}
|
|
185
|
+
EOF`;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
const type = context.build.config.docker?.type ?? fallbackType;
|
|
190
|
+
return type ? BUILT_IN_ENSURE_DOCKERFILE_SCRIPTS[type] : null;
|
|
191
|
+
}
|
|
192
|
+
return fallbackType ? BUILT_IN_ENSURE_DOCKERFILE_SCRIPTS[fallbackType] : null;
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
export const getDockerBuildScriptWithBuiltInDockerFile = (
|
|
196
|
+
context: ComponentContextWithBuild,
|
|
197
|
+
fallbackType?: BuildConfigDocker["type"],
|
|
198
|
+
) => {
|
|
179
199
|
return getDockerBuildDefaultScript(
|
|
180
200
|
context,
|
|
181
|
-
|
|
201
|
+
getEnsureDockerFileScript(context, fallbackType),
|
|
182
202
|
);
|
|
183
203
|
};
|
|
184
204
|
export const getDockerBuildDefaultScript = (
|
package/src/build/types.ts
CHANGED
|
@@ -244,6 +244,16 @@ type BuildConfigDockerCustom = {
|
|
|
244
244
|
* Depending on your Dockerfile you may want to change it to "component"
|
|
245
245
|
*/
|
|
246
246
|
buildContextLocation?: "root" | "component";
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* EXPERIMENTAL: custom docker file content
|
|
250
|
+
*
|
|
251
|
+
* you can use some predefined variables:
|
|
252
|
+
* - $DOCKER_COPY_WORKSPACE_FILES
|
|
253
|
+
* - $DOCKER_COPY_AND_INSTALL_APP
|
|
254
|
+
* - and all default variables
|
|
255
|
+
*/
|
|
256
|
+
dockerfileContent?: string[];
|
|
247
257
|
};
|
|
248
258
|
|
|
249
259
|
export type BuildConfigDocker =
|