@catladder/pipeline 1.113.1 → 1.114.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 +2 -1
- package/dist/build/docker.js +13 -2
- package/dist/build/rails/build.js +9 -0
- package/dist/build/types.d.ts +5 -0
- package/dist/bundles/catladder-gitlab/index.js +3 -3
- package/dist/constants.js +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/examples/__snapshots__/rails-k8s-with-worker.ts.snap +2094 -0
- package/examples/rails-k8s-with-worker.ts +15 -12
- package/package.json +1 -1
- package/src/build/docker.ts +5 -0
- package/src/build/rails/build.ts +15 -1
- package/src/build/types.ts +5 -0
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { rmSync, writeFileSync } from "fs";
|
|
1
2
|
import type { Config } from "../src";
|
|
2
3
|
import { createAllPipelines } from "./__utils__/helpers";
|
|
3
4
|
|
|
4
5
|
// the image version should match your `.ruby-version`
|
|
5
|
-
const RAILS_TEST_STAGE_IMAGE = "ruby:3.2.1"
|
|
6
|
+
const RAILS_TEST_STAGE_IMAGE = "ruby:3.2.1";
|
|
6
7
|
|
|
7
8
|
const config: Config = {
|
|
8
9
|
appName: "test-app",
|
|
@@ -14,9 +15,7 @@ const config: Config = {
|
|
|
14
15
|
public: {
|
|
15
16
|
RAILS_ENV: "production",
|
|
16
17
|
},
|
|
17
|
-
secret: [
|
|
18
|
-
"SECRET_KEY_BASE",
|
|
19
|
-
]
|
|
18
|
+
secret: ["SECRET_KEY_BASE"],
|
|
20
19
|
},
|
|
21
20
|
build: {
|
|
22
21
|
type: "rails",
|
|
@@ -32,6 +31,7 @@ const config: Config = {
|
|
|
32
31
|
audit: {
|
|
33
32
|
jobImage: RAILS_TEST_STAGE_IMAGE,
|
|
34
33
|
},
|
|
34
|
+
// only needed if you do not have a Dockerfile
|
|
35
35
|
cnbBuilder: {
|
|
36
36
|
buildVars: { SECRET_KEY_BASE: "dummy-value" },
|
|
37
37
|
},
|
|
@@ -57,8 +57,7 @@ const config: Config = {
|
|
|
57
57
|
jobs: {
|
|
58
58
|
"db-migrate": {
|
|
59
59
|
hook: "post-install,post-upgrade",
|
|
60
|
-
command:
|
|
61
|
-
"launcher bundle exec rake db:migrate",
|
|
60
|
+
command: "launcher bundle exec rake db:migrate",
|
|
62
61
|
},
|
|
63
62
|
},
|
|
64
63
|
},
|
|
@@ -70,21 +69,19 @@ const config: Config = {
|
|
|
70
69
|
jobs: {
|
|
71
70
|
"db-prepare-seed": {
|
|
72
71
|
hook: "post-install",
|
|
73
|
-
command:
|
|
74
|
-
"launcher bundle exec rake db:prepare db:seed",
|
|
72
|
+
command: "launcher bundle exec rake db:prepare db:seed",
|
|
75
73
|
},
|
|
76
74
|
"db-migrate": {
|
|
77
75
|
hook: "post-upgrade",
|
|
78
|
-
command:
|
|
79
|
-
"launcher bundle exec rake db:migrate",
|
|
76
|
+
command: "launcher bundle exec rake db:migrate",
|
|
80
77
|
},
|
|
81
78
|
},
|
|
82
79
|
},
|
|
83
80
|
},
|
|
84
81
|
},
|
|
85
82
|
prod: {
|
|
86
|
-
host: "my-fancy-website.com"
|
|
87
|
-
}
|
|
83
|
+
host: "my-fancy-website.com",
|
|
84
|
+
},
|
|
88
85
|
},
|
|
89
86
|
},
|
|
90
87
|
},
|
|
@@ -93,3 +90,9 @@ const config: Config = {
|
|
|
93
90
|
it("matches snapshot", async () => {
|
|
94
91
|
expect(await createAllPipelines(config)).toMatchSnapshot();
|
|
95
92
|
});
|
|
93
|
+
|
|
94
|
+
it("matches snapshot with a Dockerfile", async () => {
|
|
95
|
+
writeFileSync("Dockerfile", "");
|
|
96
|
+
expect(await createAllPipelines(config)).toMatchSnapshot();
|
|
97
|
+
rmSync("Dockerfile");
|
|
98
|
+
});
|
package/package.json
CHANGED
package/src/build/docker.ts
CHANGED
|
@@ -3,6 +3,8 @@ import { isOfDeployType } from "../deploy";
|
|
|
3
3
|
import { getRunnerImage } from "../runner";
|
|
4
4
|
import type { Context } from "../types";
|
|
5
5
|
import type { CatladderJob } from "../types/jobs";
|
|
6
|
+
import { existsSync } from "fs";
|
|
7
|
+
import path from "path";
|
|
6
8
|
|
|
7
9
|
const DOCKER_RUNNER_BUILD_VARIABLES = {
|
|
8
10
|
KUBERNETES_CPU_REQUEST: "0.5",
|
|
@@ -104,3 +106,6 @@ export const getDockerBuildDefaultScript = (ensureDockerFileScript?: string) =>
|
|
|
104
106
|
"docker tag $DOCKER_IMAGE:$DOCKER_IMAGE_TAG $DOCKER_CACHE_IMAGE",
|
|
105
107
|
"docker push $DOCKER_CACHE_IMAGE",
|
|
106
108
|
].filter(Boolean);
|
|
109
|
+
|
|
110
|
+
export const hasDockerfile = (context: Context) =>
|
|
111
|
+
existsSync(path.join(context.componentConfig.dir, "Dockerfile"));
|
package/src/build/rails/build.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import type { Context } from "../..";
|
|
2
2
|
import type { CatladderJob } from "../../types/jobs";
|
|
3
3
|
import { createBuildJobs } from "../base";
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
getDockerBuildDefaultScript,
|
|
6
|
+
gitlabDockerLogin,
|
|
7
|
+
hasDockerfile,
|
|
8
|
+
} from "../docker";
|
|
5
9
|
import { isOfBuildType } from "../types";
|
|
6
10
|
|
|
7
11
|
export const createRailsBuildJobs = (context: Context): CatladderJob[] => {
|
|
@@ -11,6 +15,16 @@ export const createRailsBuildJobs = (context: Context): CatladderJob[] => {
|
|
|
11
15
|
throw new Error("build type is not rails");
|
|
12
16
|
}
|
|
13
17
|
|
|
18
|
+
if (hasDockerfile(context)) {
|
|
19
|
+
return createBuildJobs(context, {
|
|
20
|
+
appBuild: undefined,
|
|
21
|
+
dockerBuild: {
|
|
22
|
+
script: getDockerBuildDefaultScript(),
|
|
23
|
+
variables: {},
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
14
28
|
const cnbConf = buildConfig.cnbBuilder;
|
|
15
29
|
|
|
16
30
|
const packEnvArgs = Object.entries(cnbConf?.buildVars ?? {})
|
package/src/build/types.ts
CHANGED
|
@@ -201,6 +201,11 @@ export type BuildConfigCustom = Omit<
|
|
|
201
201
|
|
|
202
202
|
export type BuildConfigRails = BuildConfigBase & {
|
|
203
203
|
type: "rails";
|
|
204
|
+
/**
|
|
205
|
+
* The [Cloud Native Buildpacks](https://buildpacks.io/) builder configuration.
|
|
206
|
+
*
|
|
207
|
+
* Only applies when there is no `Dockerfile`.
|
|
208
|
+
*/
|
|
204
209
|
cnbBuilder?: {
|
|
205
210
|
/**
|
|
206
211
|
* The Cloud Native Buildpacks builder image to use.
|