@intentius/chant-lexicon-docker 0.124.98 → 0.124.100
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/codegen/docs-cli.d.ts +0 -1
- package/dist/codegen/docs.d.ts +0 -1
- package/dist/codegen/generate-cli.d.ts +0 -1
- package/dist/codegen/generate-compose.d.ts +0 -1
- package/dist/codegen/generate-dockerfile.d.ts +0 -1
- package/dist/codegen/generate.d.ts +0 -1
- package/dist/codegen/naming.d.ts +0 -1
- package/dist/codegen/package.d.ts +0 -1
- package/dist/codegen/patches.d.ts +0 -1
- package/dist/codegen/versions.d.ts +0 -1
- package/dist/compose-key.d.ts +0 -1
- package/dist/composites/catalog.d.ts +0 -1
- package/dist/composites/docker-otel-collector.d.ts +0 -1
- package/dist/composites/docker-web-service.d.ts +0 -1
- package/dist/composites/index.d.ts +0 -1
- package/dist/coverage.d.ts +0 -1
- package/dist/default-labels.d.ts +0 -1
- package/dist/detect.d.ts +0 -1
- package/dist/dockerfile-order.d.ts +0 -1
- package/dist/export-resources.d.ts +0 -1
- package/dist/generated/index.d.ts +0 -1
- package/dist/generated/runtime.d.ts +0 -1
- package/dist/import/adapter.d.ts +0 -1
- package/dist/import/adapter.js +4 -2
- package/dist/import/embedded.d.ts +0 -1
- package/dist/import/engine.d.ts +0 -1
- package/dist/import/generator.d.ts +9 -2
- package/dist/import/generator.js +23 -1
- package/dist/import/live-export.d.ts +0 -1
- package/dist/import/parser.d.ts +0 -1
- package/dist/import/testdata/tar.d.ts +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/integrity.json +2 -2
- package/dist/interpolation.d.ts +0 -1
- package/dist/lint/audit-catalog.d.ts +0 -1
- package/dist/lint/audit-lineage.d.ts +0 -1
- package/dist/lint/post-synth/add-url-checksum.d.ts +0 -1
- package/dist/lint/post-synth/apt-no-recommends.d.ts +0 -1
- package/dist/lint/post-synth/apt-update-alone.d.ts +0 -1
- package/dist/lint/post-synth/cache-busting-copy.d.ts +0 -1
- package/dist/lint/post-synth/copy-from-stage.d.ts +0 -1
- package/dist/lint/post-synth/docker-helpers.d.ts +0 -1
- package/dist/lint/post-synth/index.d.ts +0 -1
- package/dist/lint/post-synth/no-latest-image.d.ts +0 -1
- package/dist/lint/post-synth/no-root-user.d.ts +0 -1
- package/dist/lint/post-synth/prefer-copy.d.ts +0 -1
- package/dist/lint/post-synth/relative-workdir.d.ts +0 -1
- package/dist/lint/post-synth/repeated-cmd.d.ts +0 -1
- package/dist/lint/post-synth/root-after-user.d.ts +0 -1
- package/dist/lint/post-synth/ssh-port-exposed.d.ts +0 -1
- package/dist/lint/post-synth/unused-global-arg.d.ts +0 -1
- package/dist/lint/post-synth/unused-volume.d.ts +0 -1
- package/dist/lint/rules/data/deprecated-images.d.ts +0 -1
- package/dist/lint/rules/data/known-base-images.d.ts +0 -1
- package/dist/lint/rules/index.d.ts +0 -1
- package/dist/lint/rules/no-latest-tag.d.ts +0 -1
- package/dist/lint/rules/per-kind-order.d.ts +0 -1
- package/dist/list-artifacts.d.ts +0 -1
- package/dist/lsp/completions.d.ts +0 -1
- package/dist/lsp/hover.d.ts +0 -1
- package/dist/manifest.json +1 -1
- package/dist/package-cli.d.ts +0 -1
- package/dist/plugin.d.ts +0 -1
- package/dist/serializer.d.ts +0 -1
- package/dist/spec/fetch-compose.d.ts +0 -1
- package/dist/spec/fetch-engine.d.ts +0 -1
- package/dist/spec/parse-compose.d.ts +0 -1
- package/dist/spec/parse-engine.d.ts +0 -1
- package/dist/validate-cli.d.ts +0 -1
- package/dist/validate.d.ts +0 -1
- package/dist/variables.d.ts +0 -1
- package/package.json +8 -9
- package/dist/codegen/docs-cli.d.ts.map +0 -1
- package/dist/codegen/docs.d.ts.map +0 -1
- package/dist/codegen/generate-cli.d.ts.map +0 -1
- package/dist/codegen/generate-compose.d.ts.map +0 -1
- package/dist/codegen/generate-dockerfile.d.ts.map +0 -1
- package/dist/codegen/generate.d.ts.map +0 -1
- package/dist/codegen/naming.d.ts.map +0 -1
- package/dist/codegen/package.d.ts.map +0 -1
- package/dist/codegen/patches.d.ts.map +0 -1
- package/dist/codegen/versions.d.ts.map +0 -1
- package/dist/compose-key.d.ts.map +0 -1
- package/dist/composites/catalog.d.ts.map +0 -1
- package/dist/composites/docker-otel-collector.d.ts.map +0 -1
- package/dist/composites/docker-web-service.d.ts.map +0 -1
- package/dist/composites/index.d.ts.map +0 -1
- package/dist/coverage.d.ts.map +0 -1
- package/dist/default-labels.d.ts.map +0 -1
- package/dist/detect.d.ts.map +0 -1
- package/dist/dockerfile-order.d.ts.map +0 -1
- package/dist/export-resources.d.ts.map +0 -1
- package/dist/generated/index.d.ts.map +0 -1
- package/dist/generated/runtime.d.ts.map +0 -1
- package/dist/import/adapter.d.ts.map +0 -1
- package/dist/import/embedded.d.ts.map +0 -1
- package/dist/import/engine.d.ts.map +0 -1
- package/dist/import/generator.d.ts.map +0 -1
- package/dist/import/live-export.d.ts.map +0 -1
- package/dist/import/parser.d.ts.map +0 -1
- package/dist/import/testdata/tar.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/interpolation.d.ts.map +0 -1
- package/dist/lint/audit-catalog.d.ts.map +0 -1
- package/dist/lint/audit-lineage.d.ts.map +0 -1
- package/dist/lint/post-synth/add-url-checksum.d.ts.map +0 -1
- package/dist/lint/post-synth/apt-no-recommends.d.ts.map +0 -1
- package/dist/lint/post-synth/apt-update-alone.d.ts.map +0 -1
- package/dist/lint/post-synth/cache-busting-copy.d.ts.map +0 -1
- package/dist/lint/post-synth/copy-from-stage.d.ts.map +0 -1
- package/dist/lint/post-synth/docker-helpers.d.ts.map +0 -1
- package/dist/lint/post-synth/index.d.ts.map +0 -1
- package/dist/lint/post-synth/no-latest-image.d.ts.map +0 -1
- package/dist/lint/post-synth/no-root-user.d.ts.map +0 -1
- package/dist/lint/post-synth/prefer-copy.d.ts.map +0 -1
- package/dist/lint/post-synth/relative-workdir.d.ts.map +0 -1
- package/dist/lint/post-synth/repeated-cmd.d.ts.map +0 -1
- package/dist/lint/post-synth/root-after-user.d.ts.map +0 -1
- package/dist/lint/post-synth/ssh-port-exposed.d.ts.map +0 -1
- package/dist/lint/post-synth/unused-global-arg.d.ts.map +0 -1
- package/dist/lint/post-synth/unused-volume.d.ts.map +0 -1
- package/dist/lint/rules/data/deprecated-images.d.ts.map +0 -1
- package/dist/lint/rules/data/known-base-images.d.ts.map +0 -1
- package/dist/lint/rules/index.d.ts.map +0 -1
- package/dist/lint/rules/no-latest-tag.d.ts.map +0 -1
- package/dist/lint/rules/per-kind-order.d.ts.map +0 -1
- package/dist/list-artifacts.d.ts.map +0 -1
- package/dist/lsp/completions.d.ts.map +0 -1
- package/dist/lsp/hover.d.ts.map +0 -1
- package/dist/package-cli.d.ts.map +0 -1
- package/dist/plugin.d.ts.map +0 -1
- package/dist/serializer.d.ts.map +0 -1
- package/dist/spec/fetch-compose.d.ts.map +0 -1
- package/dist/spec/fetch-engine.d.ts.map +0 -1
- package/dist/spec/parse-compose.d.ts.map +0 -1
- package/dist/spec/parse-engine.d.ts.map +0 -1
- package/dist/validate-cli.d.ts.map +0 -1
- package/dist/validate.d.ts.map +0 -1
- package/dist/variables.d.ts.map +0 -1
- package/src/codegen/__snapshots__/okf.test.ts.snap +0 -555
- package/src/codegen/docs-cli.ts +0 -10
- package/src/codegen/docs.ts +0 -171
- package/src/codegen/generate-cli.ts +0 -36
- package/src/codegen/generate-compose.ts +0 -21
- package/src/codegen/generate-dockerfile.ts +0 -21
- package/src/codegen/generate.test.ts +0 -115
- package/src/codegen/generate.ts +0 -258
- package/src/codegen/naming.test.ts +0 -81
- package/src/codegen/naming.ts +0 -54
- package/src/codegen/okf.test.ts +0 -36
- package/src/codegen/package.ts +0 -59
- package/src/codegen/patches.ts +0 -42
- package/src/codegen/versions.ts +0 -46
- package/src/compose-key.ts +0 -31
- package/src/composites/catalog.test.ts +0 -39
- package/src/composites/catalog.ts +0 -118
- package/src/composites/docker-otel-collector.ts +0 -83
- package/src/composites/docker-web-service.test.ts +0 -34
- package/src/composites/docker-web-service.ts +0 -75
- package/src/composites/index.ts +0 -9
- package/src/coverage.test.ts +0 -33
- package/src/coverage.ts +0 -54
- package/src/default-labels.test.ts +0 -85
- package/src/default-labels.ts +0 -72
- package/src/detect.ts +0 -7
- package/src/dockerfile-order.ts +0 -20
- package/src/docs-examples.test.ts +0 -141
- package/src/export-resources.ts +0 -90
- package/src/generated/index.d.ts +0 -407
- package/src/generated/index.ts +0 -410
- package/src/generated/runtime.ts +0 -4
- package/src/import/adapter.ts +0 -99
- package/src/import/embedded-live.test.ts +0 -250
- package/src/import/embedded.ts +0 -83
- package/src/import/engine.ts +0 -107
- package/src/import/generator.test.ts +0 -134
- package/src/import/generator.ts +0 -202
- package/src/import/live-export.test.ts +0 -271
- package/src/import/live-export.ts +0 -359
- package/src/import/parser.test.ts +0 -137
- package/src/import/parser.ts +0 -269
- package/src/import/roundtrip.test.ts +0 -257
- package/src/import/testdata/configs-secrets.yaml +0 -15
- package/src/import/testdata/full.yaml +0 -43
- package/src/import/testdata/names-and-fields.yaml +0 -44
- package/src/import/testdata/simple.yaml +0 -9
- package/src/import/testdata/tar.ts +0 -24
- package/src/import/testdata/webapp.yaml +0 -41
- package/src/index.ts +0 -32
- package/src/interpolation.test.ts +0 -41
- package/src/interpolation.ts +0 -76
- package/src/lint/audit-catalog.ts +0 -28
- package/src/lint/audit-lineage.ts +0 -48
- package/src/lint/post-synth/add-url-checksum.ts +0 -38
- package/src/lint/post-synth/apt-no-recommends.ts +0 -43
- package/src/lint/post-synth/apt-update-alone.ts +0 -39
- package/src/lint/post-synth/cache-busting-copy.ts +0 -65
- package/src/lint/post-synth/copy-from-stage.ts +0 -54
- package/src/lint/post-synth/docker-helpers.ts +0 -194
- package/src/lint/post-synth/index.ts +0 -33
- package/src/lint/post-synth/no-latest-image.ts +0 -36
- package/src/lint/post-synth/no-root-user.ts +0 -38
- package/src/lint/post-synth/post-synth.test.ts +0 -330
- package/src/lint/post-synth/prefer-copy.ts +0 -53
- package/src/lint/post-synth/relative-workdir.ts +0 -38
- package/src/lint/post-synth/repeated-cmd.ts +0 -35
- package/src/lint/post-synth/root-after-user.ts +0 -44
- package/src/lint/post-synth/ssh-port-exposed.ts +0 -68
- package/src/lint/post-synth/unused-global-arg.ts +0 -38
- package/src/lint/post-synth/unused-volume.ts +0 -49
- package/src/lint/rules/data/deprecated-images.ts +0 -28
- package/src/lint/rules/data/known-base-images.ts +0 -20
- package/src/lint/rules/index.ts +0 -6
- package/src/lint/rules/no-latest-tag.ts +0 -63
- package/src/lint/rules/per-kind-order.ts +0 -130
- package/src/lint/rules/rules.test.ts +0 -170
- package/src/list-artifacts.test.ts +0 -141
- package/src/list-artifacts.ts +0 -164
- package/src/lsp/completions.test.ts +0 -40
- package/src/lsp/completions.ts +0 -21
- package/src/lsp/hover.test.ts +0 -35
- package/src/lsp/hover.ts +0 -39
- package/src/package-cli.ts +0 -25
- package/src/plugin.test.ts +0 -121
- package/src/plugin.ts +0 -268
- package/src/serializer.test.ts +0 -545
- package/src/serializer.ts +0 -444
- package/src/skills/chant-docker-patterns.md +0 -222
- package/src/skills/chant-docker.md +0 -156
- package/src/spec/fetch-compose.ts +0 -35
- package/src/spec/fetch-engine.ts +0 -25
- package/src/spec/parse-compose.ts +0 -195
- package/src/spec/parse-engine.ts +0 -59
- package/src/typecheck.e2e.test.ts +0 -125
- package/src/typed-props.test.ts +0 -60
- package/src/validate-cli.ts +0 -19
- package/src/validate.test.ts +0 -16
- package/src/validate.ts +0 -44
- package/src/variables.test.ts +0 -32
- package/src/variables.ts +0 -47
- /package/{src → dist}/generated/lexicon-docker.json +0 -0
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { describe, test, expect } from "vitest";
|
|
2
|
-
import {
|
|
3
|
-
entityTypeToTsName,
|
|
4
|
-
tsNameToEntityType,
|
|
5
|
-
isComposeType,
|
|
6
|
-
isDockerfileType,
|
|
7
|
-
ALL_ENTITY_TYPES,
|
|
8
|
-
} from "./naming";
|
|
9
|
-
|
|
10
|
-
describe("entityTypeToTsName", () => {
|
|
11
|
-
test("maps Compose Service", () => {
|
|
12
|
-
expect(entityTypeToTsName("Docker::Compose::Service")).toBe("Service");
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
test("maps Compose Volume", () => {
|
|
16
|
-
expect(entityTypeToTsName("Docker::Compose::Volume")).toBe("Volume");
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
test("maps Compose Network", () => {
|
|
20
|
-
expect(entityTypeToTsName("Docker::Compose::Network")).toBe("Network");
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
test("maps Compose Config with disambiguation", () => {
|
|
24
|
-
expect(entityTypeToTsName("Docker::Compose::Config")).toBe("DockerConfig");
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
test("maps Compose Secret with disambiguation", () => {
|
|
28
|
-
expect(entityTypeToTsName("Docker::Compose::Secret")).toBe("DockerSecret");
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
test("maps Dockerfile", () => {
|
|
32
|
-
expect(entityTypeToTsName("Docker::Dockerfile")).toBe("Dockerfile");
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
test("falls back to last segment for unknown types", () => {
|
|
36
|
-
expect(entityTypeToTsName("Docker::Unknown::Foo")).toBe("Foo");
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
describe("tsNameToEntityType", () => {
|
|
41
|
-
test("reverse maps Service", () => {
|
|
42
|
-
expect(tsNameToEntityType("Service")).toBe("Docker::Compose::Service");
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
test("reverse maps Dockerfile", () => {
|
|
46
|
-
expect(tsNameToEntityType("Dockerfile")).toBe("Docker::Dockerfile");
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
test("returns undefined for unknown name", () => {
|
|
50
|
-
expect(tsNameToEntityType("Unknown")).toBeUndefined();
|
|
51
|
-
});
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
describe("isComposeType", () => {
|
|
55
|
-
test("true for Compose types", () => {
|
|
56
|
-
expect(isComposeType("Docker::Compose::Service")).toBe(true);
|
|
57
|
-
expect(isComposeType("Docker::Compose::Volume")).toBe(true);
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
test("false for Dockerfile", () => {
|
|
61
|
-
expect(isComposeType("Docker::Dockerfile")).toBe(false);
|
|
62
|
-
});
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
describe("isDockerfileType", () => {
|
|
66
|
-
test("true for Dockerfile", () => {
|
|
67
|
-
expect(isDockerfileType("Docker::Dockerfile")).toBe(true);
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
test("false for Compose types", () => {
|
|
71
|
-
expect(isDockerfileType("Docker::Compose::Service")).toBe(false);
|
|
72
|
-
});
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
describe("ALL_ENTITY_TYPES", () => {
|
|
76
|
-
test("contains all six types", () => {
|
|
77
|
-
expect(ALL_ENTITY_TYPES).toHaveLength(6);
|
|
78
|
-
expect(ALL_ENTITY_TYPES).toContain("Docker::Compose::Service");
|
|
79
|
-
expect(ALL_ENTITY_TYPES).toContain("Docker::Dockerfile");
|
|
80
|
-
});
|
|
81
|
-
});
|
package/src/codegen/naming.ts
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Naming strategy for Docker lexicon entities.
|
|
3
|
-
*
|
|
4
|
-
* Converts Docker/Compose entity type names to TypeScript class names.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
/** Map entityType → TypeScript class name */
|
|
8
|
-
const ENTITY_TYPE_TO_TS_NAME: Record<string, string> = {
|
|
9
|
-
"Docker::Compose::Service": "Service",
|
|
10
|
-
"Docker::Compose::Volume": "Volume",
|
|
11
|
-
"Docker::Compose::Network": "Network",
|
|
12
|
-
"Docker::Compose::Config": "DockerConfig",
|
|
13
|
-
"Docker::Compose::Secret": "DockerSecret",
|
|
14
|
-
"Docker::Dockerfile": "Dockerfile",
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
/** Map TypeScript class name → entityType */
|
|
18
|
-
const TS_NAME_TO_ENTITY_TYPE: Record<string, string> = Object.fromEntries(
|
|
19
|
-
Object.entries(ENTITY_TYPE_TO_TS_NAME).map(([k, v]) => [v, k]),
|
|
20
|
-
);
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Convert a Docker entity type name to a TypeScript class name.
|
|
24
|
-
* e.g. "Docker::Compose::Service" → "Service"
|
|
25
|
-
*/
|
|
26
|
-
export function entityTypeToTsName(entityType: string): string {
|
|
27
|
-
return ENTITY_TYPE_TO_TS_NAME[entityType] ?? entityType.split("::").pop() ?? entityType;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Convert a TypeScript class name back to an entity type.
|
|
32
|
-
*/
|
|
33
|
-
export function tsNameToEntityType(tsName: string): string | undefined {
|
|
34
|
-
return TS_NAME_TO_ENTITY_TYPE[tsName];
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* All known Docker entity types, in declaration order.
|
|
39
|
-
*/
|
|
40
|
-
export const ALL_ENTITY_TYPES = Object.keys(ENTITY_TYPE_TO_TS_NAME);
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Check whether an entity type is a Compose resource.
|
|
44
|
-
*/
|
|
45
|
-
export function isComposeType(entityType: string): boolean {
|
|
46
|
-
return entityType.startsWith("Docker::Compose::");
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Check whether an entity type is the Dockerfile resource.
|
|
51
|
-
*/
|
|
52
|
-
export function isDockerfileType(entityType: string): boolean {
|
|
53
|
-
return entityType === "Docker::Dockerfile";
|
|
54
|
-
}
|
package/src/codegen/okf.test.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { describe, test, expect } from "vitest";
|
|
2
|
-
import { packageLexicon } from "./package";
|
|
3
|
-
import { okfConformanceProblems, splitFrontmatter } from "@intentius/chant/okf";
|
|
4
|
-
import { parseYAML } from "@intentius/chant/yaml";
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* The lexicon OKF bundle (#1060) over docker — the hand-authored generation
|
|
8
|
-
* path, where descriptions live in the registry itself. Small enough to
|
|
9
|
-
* snapshot whole.
|
|
10
|
-
*/
|
|
11
|
-
describe("docker OKF bundle", () => {
|
|
12
|
-
test("packaging emits a conformant, snapshot-stable bundle", async () => {
|
|
13
|
-
const { spec } = await packageLexicon();
|
|
14
|
-
expect(spec.okf).toBeDefined();
|
|
15
|
-
expect(okfConformanceProblems(spec.okf!)).toEqual([]);
|
|
16
|
-
expect(spec.okf).toMatchSnapshot();
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
test("resource concepts and rules cross-link in both directions", async () => {
|
|
20
|
-
const { spec } = await packageLexicon();
|
|
21
|
-
const files = new Map(spec.okf!.map((f) => [f.path, f.content]));
|
|
22
|
-
|
|
23
|
-
const service = splitFrontmatter(files.get("types/Service.md")!)!;
|
|
24
|
-
const front = parseYAML(service.frontmatter);
|
|
25
|
-
expect(front.type).toBe("resource-type");
|
|
26
|
-
expect(front.resource_type).toBe("Docker::Compose::Service");
|
|
27
|
-
// Registry-carried property description reaches the concept body.
|
|
28
|
-
expect(service.body).toContain("- `image` (`ComposeString`): Specify the image to start the container from.");
|
|
29
|
-
// The no-latest-tag rule governs Service…
|
|
30
|
-
expect(service.body).toContain("[DKRS001](/rules/DKRS001.md)");
|
|
31
|
-
// …and points back at it.
|
|
32
|
-
const rule = splitFrontmatter(files.get("rules/DKRS001.md")!)!;
|
|
33
|
-
expect(parseYAML(rule.frontmatter).severity).toBe("warning");
|
|
34
|
-
expect(rule.body).toContain("- [Service](/types/Service.md)");
|
|
35
|
-
});
|
|
36
|
-
});
|
package/src/codegen/package.ts
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Docker lexicon packaging — delegates to core packagePipeline.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { readFileSync } from "fs";
|
|
6
|
-
import { dockerPlugin } from "../plugin";
|
|
7
|
-
import { join, dirname } from "path";
|
|
8
|
-
import { moduleSourceDir } from "@intentius/chant/module-source";
|
|
9
|
-
import type { IntrinsicDef } from "@intentius/chant/lexicon";
|
|
10
|
-
import {
|
|
11
|
-
packagePipeline,
|
|
12
|
-
collectSkills,
|
|
13
|
-
type PackageOptions,
|
|
14
|
-
type PackageResult,
|
|
15
|
-
} from "@intentius/chant/codegen/package";
|
|
16
|
-
import { generate } from "./generate";
|
|
17
|
-
|
|
18
|
-
export type { PackageOptions, PackageResult };
|
|
19
|
-
|
|
20
|
-
const pkgDir = dirname(moduleSourceDir(import.meta.url));
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Package the Docker lexicon into a distributable BundleSpec.
|
|
24
|
-
*/
|
|
25
|
-
export async function packageLexicon(opts: PackageOptions = {}): Promise<PackageResult> {
|
|
26
|
-
const pkgJson = JSON.parse(readFileSync(join(pkgDir, "..", "package.json"), "utf-8"));
|
|
27
|
-
|
|
28
|
-
return packagePipeline(
|
|
29
|
-
{
|
|
30
|
-
generate: (genOpts) => generate({ verbose: genOpts.verbose, force: genOpts.force }),
|
|
31
|
-
|
|
32
|
-
buildManifest: (_genResult) => {
|
|
33
|
-
// Derived from the plugin's own registration (chant #1067) — this
|
|
34
|
-
// used to be a hand-maintained array independent of ../plugin.ts,
|
|
35
|
-
// free to drift from the real registration without anything
|
|
36
|
-
// noticing.
|
|
37
|
-
const intrinsics: IntrinsicDef[] = dockerPlugin.intrinsics?.() ?? [];
|
|
38
|
-
|
|
39
|
-
return {
|
|
40
|
-
name: "docker",
|
|
41
|
-
version: pkgJson.version ?? "0.0.0",
|
|
42
|
-
chantVersion: ">=0.1.0",
|
|
43
|
-
namespace: "Docker",
|
|
44
|
-
intrinsics,
|
|
45
|
-
pseudoParameters: {},
|
|
46
|
-
};
|
|
47
|
-
},
|
|
48
|
-
|
|
49
|
-
srcDir: pkgDir,
|
|
50
|
-
|
|
51
|
-
collectSkills: () => { const skillDefs = dockerPlugin.skills?.() ?? [];
|
|
52
|
-
return collectSkills(skillDefs);
|
|
53
|
-
},
|
|
54
|
-
|
|
55
|
-
version: pkgJson.version ?? "0.0.0",
|
|
56
|
-
},
|
|
57
|
-
opts,
|
|
58
|
-
);
|
|
59
|
-
}
|
package/src/codegen/patches.ts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Manual overrides for upstream Docker spec quirks.
|
|
3
|
-
*
|
|
4
|
-
* These patches adjust entity names, property types, or descriptions
|
|
5
|
-
* where the upstream spec is ambiguous, incorrect, or overly broad.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
export interface EntityPatch {
|
|
9
|
-
/** Override entity description */
|
|
10
|
-
description?: string;
|
|
11
|
-
/** Override specific property types */
|
|
12
|
-
propertyOverrides?: Record<string, { type?: string; description?: string }>;
|
|
13
|
-
/** Properties to exclude from type generation */
|
|
14
|
-
excludeProperties?: string[];
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Patches keyed by entity typeName.
|
|
19
|
-
*/
|
|
20
|
-
export const ENTITY_PATCHES: Record<string, EntityPatch> = {
|
|
21
|
-
"Docker::Compose::Service": {
|
|
22
|
-
propertyOverrides: {
|
|
23
|
-
// The spec allows both string and object forms for these — normalize to object
|
|
24
|
-
depends_on: {
|
|
25
|
-
description: "Service dependencies (may be string[] or condition map)",
|
|
26
|
-
},
|
|
27
|
-
// healthcheck interval/timeout are duration strings in Docker syntax
|
|
28
|
-
healthcheck: {
|
|
29
|
-
description: "Health check configuration with Docker duration strings (e.g., '30s', '1m30s')",
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
},
|
|
33
|
-
|
|
34
|
-
"Docker::Dockerfile": {
|
|
35
|
-
propertyOverrides: {
|
|
36
|
-
// Multi-stage builds use stages array
|
|
37
|
-
stages: {
|
|
38
|
-
description: "Multi-stage build stages — each stage has its own FROM and instructions",
|
|
39
|
-
},
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
};
|
package/src/codegen/versions.ts
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Pinned URLs and version tags for upstream Docker specs.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Pinned commit of compose-spec/compose-spec (#1146).
|
|
7
|
-
*
|
|
8
|
-
* compose-spec/compose-spec has no tagged releases, so unlike
|
|
9
|
-
* ENGINE_API_URL below (pinned to the `v27.3.1` tag) there is no version tag
|
|
10
|
-
* to pin against — codegen used to fetch the default branch directly (the
|
|
11
|
-
* repo's default branch is `main`; the old URL fetched `master`, a legacy
|
|
12
|
-
* alias GitHub still redirects, but a moving-branch alias all the same).
|
|
13
|
-
* That meant a cold cache picked up whatever upstream state had landed since
|
|
14
|
-
* the cache last expired, while a warm cache kept serving whatever was
|
|
15
|
-
* current when it was last filled — the exact CI nondeterminism this fix
|
|
16
|
-
* closed for azure (#1144).
|
|
17
|
-
*
|
|
18
|
-
* Pinning to a commit SHA makes generation reproducible regardless of cache
|
|
19
|
-
* state. Bump policy: #523's scheduled lexicon-upgrade cron (rolling-spec
|
|
20
|
-
* bucket) is meant to propose bumps to this constant as a reviewable PR once
|
|
21
|
-
* built. Until then, bump by hand: take the current `main` HEAD sha from
|
|
22
|
-
* https://github.com/compose-spec/compose-spec/commits/main, regenerate, fix
|
|
23
|
-
* up any composite left referencing a renamed or vanished export, and update
|
|
24
|
-
* this constant + comment.
|
|
25
|
-
*/
|
|
26
|
-
export const COMPOSE_SPEC_COMMIT = "11296e387ba76c77db1db768b9153a4304a3c9bd";
|
|
27
|
-
|
|
28
|
-
/** Compose Spec JSON Schema — pinned to COMPOSE_SPEC_COMMIT, not a moving branch */
|
|
29
|
-
export const COMPOSE_SPEC_URL = `https://raw.githubusercontent.com/compose-spec/compose-spec/${COMPOSE_SPEC_COMMIT}/schema/compose-spec.json`;
|
|
30
|
-
|
|
31
|
-
/** Docker Engine API OpenAPI spec (v1.45) */
|
|
32
|
-
export const ENGINE_API_URL =
|
|
33
|
-
"https://raw.githubusercontent.com/moby/moby/v27.3.1/api/swagger.yaml";
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Cache filenames under ~/.chant/.
|
|
37
|
-
*
|
|
38
|
-
* COMPOSE_SPEC_CACHE embeds the pin so a stale schema file fetched before a
|
|
39
|
-
* bump can never satisfy the new pin: restoring an old ~/.chant (e.g. a CI
|
|
40
|
-
* cache partial-key fallback, or a developer's pre-existing cache) simply
|
|
41
|
-
* misses this filename and re-downloads, instead of silently serving
|
|
42
|
-
* pre-bump schema under a name that still matches (#1146, mirroring azure's
|
|
43
|
-
* AZURE_SCHEMA_COMMIT-keyed cache filename, #1144).
|
|
44
|
-
*/
|
|
45
|
-
export const COMPOSE_SPEC_CACHE = `docker-compose-spec-${COMPOSE_SPEC_COMMIT}.json`;
|
|
46
|
-
export const ENGINE_API_CACHE = "docker-engine-api.yaml";
|
package/src/compose-key.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The key an entity takes in docker-compose.yml.
|
|
3
|
-
*
|
|
4
|
-
* A compose entity's key is its export name by default. A key that is not a
|
|
5
|
-
* TypeScript identifier (`db-password`, `nginx.conf`) cannot be an export
|
|
6
|
-
* name, so `composeKey` sets it explicitly (#3937):
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* export const dbPassword = composeKey("db-password", new DockerSecret({ file: "./db-password.txt" }));
|
|
10
|
-
*
|
|
11
|
-
* References to the entity (`secrets: [dbPassword]`) serialize as the key.
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
import type { Declarable } from "@intentius/chant/declarable";
|
|
15
|
-
|
|
16
|
-
export const COMPOSE_KEY = Symbol.for("docker.composeKey");
|
|
17
|
-
|
|
18
|
-
/** Give a compose entity an explicit key in docker-compose.yml. Returns the entity. */
|
|
19
|
-
export function composeKey<T extends Declarable>(key: string, entity: T): T {
|
|
20
|
-
if (typeof key !== "string" || key === "") {
|
|
21
|
-
throw new Error("composeKey: the key must be a non-empty string");
|
|
22
|
-
}
|
|
23
|
-
Object.defineProperty(entity, COMPOSE_KEY, { value: key, enumerable: false, configurable: true });
|
|
24
|
-
return entity;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/** The key set by `composeKey`, or undefined. */
|
|
28
|
-
export function getComposeKey(entity: Declarable): string | undefined {
|
|
29
|
-
const key = (entity as unknown as Record<symbol, unknown>)[COMPOSE_KEY];
|
|
30
|
-
return typeof key === "string" ? key : undefined;
|
|
31
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The composite catalog matches what this lexicon exports (#2662).
|
|
3
|
-
*
|
|
4
|
-
* `catalog.ts` is generated by `npm run generate:composite-catalogs` and is
|
|
5
|
-
* what `chant serve mcp` lists. A composite added without regenerating it would
|
|
6
|
-
* be invisible to an agent asking what docker offers; one renamed or removed
|
|
7
|
-
* would be offered and fail to import.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import { describe, expect, test } from "vitest";
|
|
11
|
-
import { isCompositeDefinition } from "@intentius/chant";
|
|
12
|
-
import * as composites from "./index";
|
|
13
|
-
import { compositeCatalog } from "./catalog";
|
|
14
|
-
import { dockerPlugin } from "../plugin";
|
|
15
|
-
|
|
16
|
-
const exported = Object.entries(composites)
|
|
17
|
-
.filter(([, value]) => isCompositeDefinition(value))
|
|
18
|
-
.map(([name]) => name)
|
|
19
|
-
.sort();
|
|
20
|
-
const catalogued = compositeCatalog.map((entry) => entry.name).sort();
|
|
21
|
-
|
|
22
|
-
describe("the docker composite catalog", () => {
|
|
23
|
-
test("every exported composite has an entry, and every entry names an exported composite", () => {
|
|
24
|
-
expect(exported.length).toBeGreaterThan(0);
|
|
25
|
-
expect(catalogued, "regenerate with `npm run generate:composite-catalogs -- docker`").toEqual(exported);
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
test("every entry says what it is and what it bundles", () => {
|
|
29
|
-
for (const entry of compositeCatalog) {
|
|
30
|
-
expect(entry.lexicon, entry.name).toBe("docker");
|
|
31
|
-
expect(entry.description.length, entry.name).toBeGreaterThan(0);
|
|
32
|
-
expect(entry.bundles.length, entry.name).toBeGreaterThan(0);
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
test("the plugin contributes it", () => {
|
|
37
|
-
expect(dockerPlugin.composites?.()).toBe(compositeCatalog);
|
|
38
|
-
});
|
|
39
|
-
});
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
// Generated by scripts/generate-composite-catalogs.ts (#2662) from this
|
|
2
|
-
// lexicon's composite exports. Do not edit by hand: run
|
|
3
|
-
// `npm run generate:composite-catalogs`. catalog.test.ts holds it to the exports.
|
|
4
|
-
import type { CompositeEntry } from "@intentius/chant/lexicon";
|
|
5
|
-
|
|
6
|
-
export const compositeCatalog: CompositeEntry[] = [
|
|
7
|
-
{
|
|
8
|
-
"name": "DockerOtelCollector",
|
|
9
|
-
"lexicon": "docker",
|
|
10
|
-
"description": "Create a DockerOtelCollector composite.",
|
|
11
|
-
"bundles": [
|
|
12
|
-
"DockerConfig",
|
|
13
|
-
"Service"
|
|
14
|
-
],
|
|
15
|
-
"params": [
|
|
16
|
-
{
|
|
17
|
-
"name": "image",
|
|
18
|
-
"type": "string",
|
|
19
|
-
"required": false,
|
|
20
|
-
"description": "Collector image (default: the contrib image at the otel lexicon's pinned collector version)."
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
"name": "config",
|
|
24
|
-
"type": "Iterable<Declarable>",
|
|
25
|
-
"required": false,
|
|
26
|
-
"description": "The collector config, as otel lexicon entities (components and pipelines)."
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
"name": "exporters",
|
|
30
|
-
"type": "OTelComponent<\"exporter\", string, any>[]",
|
|
31
|
-
"required": false,
|
|
32
|
-
"description": "Exporters for the default config (default: one `debug` exporter)."
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
"name": "signals",
|
|
36
|
-
"type": "Signal[]",
|
|
37
|
-
"required": false,
|
|
38
|
-
"description": "Signals the default config has pipelines for (default: traces, metrics and logs)."
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
"name": "publishPorts",
|
|
42
|
-
"type": "boolean",
|
|
43
|
-
"required": false,
|
|
44
|
-
"description": "Publish the receiver ports on the host (default: true)."
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
"name": "restart",
|
|
48
|
-
"type": "string",
|
|
49
|
-
"required": false,
|
|
50
|
-
"description": "Restart policy (default: \"unless-stopped\")."
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
"name": "defaults",
|
|
54
|
-
"type": "{ service?: Partial<Record<string, unknown>>; config?: Partial<Record<string, unknown>>; }",
|
|
55
|
-
"required": false,
|
|
56
|
-
"description": "Per-member defaults for fine-grained overrides."
|
|
57
|
-
}
|
|
58
|
-
]
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
"name": "DockerWebService",
|
|
62
|
-
"lexicon": "docker",
|
|
63
|
-
"description": "One HTTP service as a Compose service, with a published port and an HTTP health check.",
|
|
64
|
-
"bundles": [
|
|
65
|
-
"Service"
|
|
66
|
-
],
|
|
67
|
-
"params": [
|
|
68
|
-
{
|
|
69
|
-
"name": "build",
|
|
70
|
-
"type": "{ context: string; dockerfile?: string }",
|
|
71
|
-
"required": false,
|
|
72
|
-
"description": "Build the image from a Dockerfile: the context, and the Dockerfile's path in it (default: \"Dockerfile\")."
|
|
73
|
-
},
|
|
74
|
-
{
|
|
75
|
-
"name": "image",
|
|
76
|
-
"type": "string",
|
|
77
|
-
"required": false,
|
|
78
|
-
"description": "The image to run, or the tag to give the built one."
|
|
79
|
-
},
|
|
80
|
-
{
|
|
81
|
-
"name": "port",
|
|
82
|
-
"type": "number",
|
|
83
|
-
"required": true,
|
|
84
|
-
"description": "The port the app listens on in the container."
|
|
85
|
-
},
|
|
86
|
-
{
|
|
87
|
-
"name": "hostPort",
|
|
88
|
-
"type": "number",
|
|
89
|
-
"required": false,
|
|
90
|
-
"description": "The port published on the host (default: `port`)."
|
|
91
|
-
},
|
|
92
|
-
{
|
|
93
|
-
"name": "environment",
|
|
94
|
-
"type": "Record<string, string>",
|
|
95
|
-
"required": false,
|
|
96
|
-
"description": "More environment variables."
|
|
97
|
-
},
|
|
98
|
-
{
|
|
99
|
-
"name": "healthPath",
|
|
100
|
-
"type": "string",
|
|
101
|
-
"required": false,
|
|
102
|
-
"description": "An HTTP path the health check fetches with `wget` inside the container (default: no health check)."
|
|
103
|
-
},
|
|
104
|
-
{
|
|
105
|
-
"name": "restart",
|
|
106
|
-
"type": "string",
|
|
107
|
-
"required": false,
|
|
108
|
-
"description": "Restart policy (default: \"unless-stopped\")."
|
|
109
|
-
},
|
|
110
|
-
{
|
|
111
|
-
"name": "defaults",
|
|
112
|
-
"type": "{ service?: Partial<Record<string, unknown>>; }",
|
|
113
|
-
"required": false,
|
|
114
|
-
"description": "Per-member defaults for fine-grained overrides."
|
|
115
|
-
}
|
|
116
|
-
]
|
|
117
|
-
}
|
|
118
|
-
];
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* DockerOtelCollector composite: an OpenTelemetry Collector as a Compose
|
|
3
|
-
* service.
|
|
4
|
-
*
|
|
5
|
-
* The collector config is declared with the otel lexicon
|
|
6
|
-
* (`@intentius/chant-lexicon-otel`), rendered with `collectorYaml`, and
|
|
7
|
-
* carried inline in a top-level Compose config that the service mounts. The
|
|
8
|
-
* published ports are read back from the config, so they follow whatever
|
|
9
|
-
* config is passed in.
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
import { Composite, mergeDefaults } from "@intentius/chant";
|
|
13
|
-
import type { Declarable } from "@intentius/chant/declarable";
|
|
14
|
-
import {
|
|
15
|
-
buildCollectorConfig,
|
|
16
|
-
collectorEndpoints,
|
|
17
|
-
collectorYaml,
|
|
18
|
-
otlpCollector,
|
|
19
|
-
COLLECTOR_CONFIG_PATH,
|
|
20
|
-
COLLECTOR_IMAGE,
|
|
21
|
-
type OTelComponent,
|
|
22
|
-
type Signal,
|
|
23
|
-
} from "@intentius/chant-lexicon-otel";
|
|
24
|
-
import { Service, DockerConfig } from "../generated/index";
|
|
25
|
-
|
|
26
|
-
export interface DockerOtelCollectorProps {
|
|
27
|
-
/** Collector image (default: the contrib image at the otel lexicon's pinned collector version). */
|
|
28
|
-
image?: string;
|
|
29
|
-
/**
|
|
30
|
-
* The collector config, as otel lexicon entities (components and
|
|
31
|
-
* pipelines). Replaces the default config, and `exporters` and `signals`
|
|
32
|
-
* are then ignored.
|
|
33
|
-
*/
|
|
34
|
-
config?: Iterable<Declarable>;
|
|
35
|
-
/** Exporters for the default config (default: one `debug` exporter). */
|
|
36
|
-
exporters?: OTelComponent<"exporter", string, any>[];
|
|
37
|
-
/** Signals the default config has pipelines for (default: traces, metrics and logs). */
|
|
38
|
-
signals?: Signal[];
|
|
39
|
-
/** Publish the receiver ports on the host (default: true). Other services on the network reach the collector either way. */
|
|
40
|
-
publishPorts?: boolean;
|
|
41
|
-
/** Restart policy (default: "unless-stopped"). */
|
|
42
|
-
restart?: string;
|
|
43
|
-
/** Per-member defaults for fine-grained overrides. */
|
|
44
|
-
defaults?: {
|
|
45
|
-
service?: Partial<Record<string, unknown>>;
|
|
46
|
-
config?: Partial<Record<string, unknown>>;
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Create a DockerOtelCollector composite. Returns a Compose service and the
|
|
52
|
-
* config it mounts. The service key is the export name plus `Service`.
|
|
53
|
-
*
|
|
54
|
-
* @example
|
|
55
|
-
* ```ts
|
|
56
|
-
* import { DockerOtelCollector } from "@intentius/chant-lexicon-docker";
|
|
57
|
-
* import { OtlpExporter } from "@intentius/chant-lexicon-otel";
|
|
58
|
-
*
|
|
59
|
-
* export const otel = DockerOtelCollector({
|
|
60
|
-
* exporters: [new OtlpExporter({ endpoint: "tempo:4317", tls: { insecure: true } })],
|
|
61
|
-
* });
|
|
62
|
-
* ```
|
|
63
|
-
*/
|
|
64
|
-
export const DockerOtelCollector = Composite((props: DockerOtelCollectorProps) => {
|
|
65
|
-
const { image = COLLECTOR_IMAGE, publishPorts = true, restart = "unless-stopped", defaults: defs } = props;
|
|
66
|
-
|
|
67
|
-
const entities = props.config ? [...props.config] : otlpCollector({ exporters: props.exporters, signals: props.signals });
|
|
68
|
-
const { ports } = collectorEndpoints(buildCollectorConfig(entities).config);
|
|
69
|
-
|
|
70
|
-
const config = new DockerConfig(mergeDefaults({
|
|
71
|
-
content: collectorYaml(entities),
|
|
72
|
-
}, defs?.config));
|
|
73
|
-
|
|
74
|
-
const service = new Service(mergeDefaults({
|
|
75
|
-
image,
|
|
76
|
-
command: [`--config=${COLLECTOR_CONFIG_PATH}`],
|
|
77
|
-
configs: [{ source: config, target: COLLECTOR_CONFIG_PATH }],
|
|
78
|
-
...(publishPorts && ports.length > 0 ? { ports: ports.map((p) => `${p.port}:${p.port}${p.protocol ? "/udp" : ""}`) } : {}),
|
|
79
|
-
restart,
|
|
80
|
-
}, defs?.service));
|
|
81
|
-
|
|
82
|
-
return { service, config };
|
|
83
|
-
}, "DockerOtelCollector");
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from "vitest";
|
|
2
|
-
import { expandComposite } from "@intentius/chant";
|
|
3
|
-
import { DockerWebService } from "./docker-web-service";
|
|
4
|
-
|
|
5
|
-
const props = (s: unknown) => (s as { props: Record<string, unknown> }).props;
|
|
6
|
-
|
|
7
|
-
describe("DockerWebService", () => {
|
|
8
|
-
test("one Compose service, keyed by the export name plus Service", () => {
|
|
9
|
-
const expanded = expandComposite("app", DockerWebService({ build: { context: "../app" }, port: 8080 }));
|
|
10
|
-
expect([...expanded.keys()]).toEqual(["appService"]);
|
|
11
|
-
expect(expanded.get("appService")?.entityType).toBe("Docker::Compose::Service");
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
test("builds from the Dockerfile, publishes the port, passes it as PORT, and checks the health path", () => {
|
|
15
|
-
const { service } = DockerWebService({ build: { context: "../app" }, image: "app:local", port: 8080, healthPath: "/healthz" }).members;
|
|
16
|
-
expect(props(service)).toEqual({
|
|
17
|
-
build: { context: "../app", dockerfile: "Dockerfile" },
|
|
18
|
-
image: "app:local",
|
|
19
|
-
ports: ["8080:8080"],
|
|
20
|
-
environment: { PORT: "8080" },
|
|
21
|
-
restart: "unless-stopped",
|
|
22
|
-
healthcheck: { test: ["CMD", "wget", "-qO-", "http://127.0.0.1:8080/healthz"], interval: "30s", timeout: "5s", retries: 3 },
|
|
23
|
-
});
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
test("an image alone, another host port, extra environment, and no health check without a path", () => {
|
|
27
|
-
const { service } = DockerWebService({ image: "nginx:1", port: 80, hostPort: 8081, environment: { MODE: "prod" } }).members;
|
|
28
|
-
expect(props(service)).toEqual({ image: "nginx:1", ports: ["8081:80"], environment: { PORT: "80", MODE: "prod" }, restart: "unless-stopped" });
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
test("needs a build or an image", () => {
|
|
32
|
-
expect(() => DockerWebService({ port: 8080 })).toThrow(/give `build`, `image`, or both/);
|
|
33
|
-
});
|
|
34
|
-
});
|