@alchemy.run/docker 2.0.0-beta.85 → 2.0.0-beta.86
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 +16 -0
- package/lib/Bootstrap.d.ts.map +1 -1
- package/lib/Bootstrap.js +2 -1
- package/lib/Bootstrap.js.map +1 -1
- package/lib/BuildCache.d.ts +87 -0
- package/lib/BuildCache.d.ts.map +1 -0
- package/lib/BuildCache.js +39 -0
- package/lib/BuildCache.js.map +1 -0
- package/lib/BuildHash.d.ts +9 -1
- package/lib/BuildHash.d.ts.map +1 -1
- package/lib/BuildHash.js +51 -19
- package/lib/BuildHash.js.map +1 -1
- package/lib/BuildPlan.d.ts +202 -0
- package/lib/BuildPlan.d.ts.map +1 -0
- package/lib/BuildPlan.js +514 -0
- package/lib/BuildPlan.js.map +1 -0
- package/lib/Container.d.ts +24 -1
- package/lib/Container.d.ts.map +1 -1
- package/lib/Container.js +14 -0
- package/lib/Container.js.map +1 -1
- package/lib/Context.d.ts +20 -1
- package/lib/Context.d.ts.map +1 -1
- package/lib/Context.js +15 -0
- package/lib/Context.js.map +1 -1
- package/lib/Docker.d.ts +33 -0
- package/lib/Docker.d.ts.map +1 -1
- package/lib/Docker.js +23 -2
- package/lib/Docker.js.map +1 -1
- package/lib/Dockerfile.d.ts +0 -2
- package/lib/Dockerfile.d.ts.map +1 -1
- package/lib/Dockerfile.js.map +1 -1
- package/lib/DockerfileParser.d.ts +125 -0
- package/lib/DockerfileParser.d.ts.map +1 -0
- package/lib/DockerfileParser.js +1040 -0
- package/lib/DockerfileParser.js.map +1 -0
- package/lib/HealthcheckCommand.d.ts.map +1 -1
- package/lib/HealthcheckCommand.js.map +1 -1
- package/lib/Image.d.ts +40 -12
- package/lib/Image.d.ts.map +1 -1
- package/lib/Image.js +41 -9
- package/lib/Image.js.map +1 -1
- package/lib/ImageArchive.d.ts +41 -0
- package/lib/ImageArchive.d.ts.map +1 -0
- package/lib/ImageArchive.js +54 -0
- package/lib/ImageArchive.js.map +1 -0
- package/lib/ImageSource.d.ts +100 -11
- package/lib/ImageSource.d.ts.map +1 -1
- package/lib/ImageSource.js +219 -73
- package/lib/ImageSource.js.map +1 -1
- package/lib/Network.d.ts +175 -3
- package/lib/Network.d.ts.map +1 -1
- package/lib/Network.js +296 -8
- package/lib/Network.js.map +1 -1
- package/lib/Providers.d.ts.map +1 -1
- package/lib/Providers.js.map +1 -1
- package/lib/Registry.d.ts.map +1 -1
- package/lib/Registry.js.map +1 -1
- package/lib/RegistryError.d.ts.map +1 -1
- package/lib/RegistryError.js.map +1 -1
- package/lib/RemoteImage.d.ts.map +1 -1
- package/lib/RemoteImage.js.map +1 -1
- package/lib/Service.d.ts.map +1 -1
- package/lib/Service.js.map +1 -1
- package/lib/ServiceImage.d.ts.map +1 -1
- package/lib/ServiceImage.js.map +1 -1
- package/lib/ShellWord.d.ts +28 -0
- package/lib/ShellWord.d.ts.map +1 -0
- package/lib/ShellWord.js +301 -0
- package/lib/ShellWord.js.map +1 -0
- package/lib/Swarm.d.ts.map +1 -1
- package/lib/Swarm.js.map +1 -1
- package/lib/Volume.d.ts +24 -1
- package/lib/Volume.d.ts.map +1 -1
- package/lib/Volume.js +16 -0
- package/lib/Volume.js.map +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js.map +1 -1
- package/package.json +9 -9
- package/src/Bootstrap.ts +2 -0
- package/src/BuildCache.ts +111 -0
- package/src/BuildHash.ts +73 -24
- package/src/BuildPlan.ts +758 -0
- package/src/Container.ts +31 -1
- package/src/Context.ts +27 -1
- package/src/Docker.ts +56 -2
- package/src/Dockerfile.ts +0 -2
- package/src/DockerfileParser.ts +1152 -0
- package/src/Image.ts +45 -14
- package/src/ImageArchive.ts +77 -0
- package/src/ImageSource.ts +322 -103
- package/src/Network.ts +432 -10
- package/src/ShellWord.ts +326 -0
- package/src/Volume.ts +33 -1
package/src/Container.ts
CHANGED
|
@@ -235,9 +235,24 @@ export interface Container extends Resource<
|
|
|
235
235
|
devices?: Container.DeviceMapping[];
|
|
236
236
|
},
|
|
237
237
|
never,
|
|
238
|
-
Providers
|
|
238
|
+
Providers,
|
|
239
|
+
ContainerLookup
|
|
239
240
|
> {}
|
|
240
241
|
|
|
242
|
+
/**
|
|
243
|
+
* Props for {@link Container.lookup}: find a container this stack
|
|
244
|
+
* doesn't manage by its name.
|
|
245
|
+
*/
|
|
246
|
+
export interface ContainerLookup {
|
|
247
|
+
/** Container name. */
|
|
248
|
+
name: string;
|
|
249
|
+
/**
|
|
250
|
+
* Docker context the engine is reached through.
|
|
251
|
+
* @default the current context
|
|
252
|
+
*/
|
|
253
|
+
context?: string;
|
|
254
|
+
}
|
|
255
|
+
|
|
241
256
|
/**
|
|
242
257
|
* A Docker container managed through the active Docker context.
|
|
243
258
|
*
|
|
@@ -436,6 +451,16 @@ export interface Container extends Resource<
|
|
|
436
451
|
* });
|
|
437
452
|
* ```
|
|
438
453
|
*
|
|
454
|
+
* ### Looking up an existing container
|
|
455
|
+
* `Container.lookup` references a container Alchemy doesn't manage (created with
|
|
456
|
+
* the Docker CLI, Compose or another stack). It is read during plan/deploy,
|
|
457
|
+
* never created, updated or removed.
|
|
458
|
+
*
|
|
459
|
+
* **Example:** Reference an existing container
|
|
460
|
+
* ```typescript
|
|
461
|
+
* const db = Docker.Container.lookup({ name: "postgres" });
|
|
462
|
+
* ```
|
|
463
|
+
*
|
|
439
464
|
* @resource
|
|
440
465
|
* @product Container
|
|
441
466
|
*/
|
|
@@ -562,6 +587,11 @@ export const ContainerProvider = () =>
|
|
|
562
587
|
|
|
563
588
|
return Container.Provider.of({
|
|
564
589
|
list: () => Effect.succeed([]),
|
|
590
|
+
lookup: Effect.fn(function* ({ name, context }) {
|
|
591
|
+
const info = yield* inspect(name, context);
|
|
592
|
+
return info ? toContainerAttributes(info, info.Config.Image) : undefined;
|
|
593
|
+
}),
|
|
594
|
+
|
|
565
595
|
read: Effect.fn(function* ({ id, instanceId, olds, output }) {
|
|
566
596
|
const context = dockerContextName(olds.context);
|
|
567
597
|
const name = yield* dockerPhysicalName(id, olds, instanceId);
|
package/src/Context.ts
CHANGED
|
@@ -41,9 +41,19 @@ export interface Context extends Resource<
|
|
|
41
41
|
docker?: string;
|
|
42
42
|
},
|
|
43
43
|
never,
|
|
44
|
-
Providers
|
|
44
|
+
Providers,
|
|
45
|
+
ContextLookup
|
|
45
46
|
> {}
|
|
46
47
|
|
|
48
|
+
/**
|
|
49
|
+
* Props for {@link Context.lookup}: find a Docker context this
|
|
50
|
+
* stack doesn't manage by its name.
|
|
51
|
+
*/
|
|
52
|
+
export interface ContextLookup {
|
|
53
|
+
/** Context name. */
|
|
54
|
+
name: string;
|
|
55
|
+
}
|
|
56
|
+
|
|
47
57
|
/**
|
|
48
58
|
* A named Docker CLI context — a pointer to a Docker engine (local socket,
|
|
49
59
|
* SSH host, or TCP endpoint) that other Docker resources deploy through.
|
|
@@ -89,6 +99,17 @@ export interface Context extends Resource<
|
|
|
89
99
|
* });
|
|
90
100
|
* ```
|
|
91
101
|
*
|
|
102
|
+
* ### Looking up an existing context
|
|
103
|
+
* `Context.lookup` references a context Alchemy doesn't manage (created with
|
|
104
|
+
* the Docker CLI, Compose or another stack). It is read during plan/deploy,
|
|
105
|
+
* never created, updated or removed.
|
|
106
|
+
*
|
|
107
|
+
* **Example:** Deploy to an existing context
|
|
108
|
+
* ```typescript
|
|
109
|
+
* const remote = Docker.Context.lookup({ name: "prod-host" });
|
|
110
|
+
* const api = yield* Docker.Container("Api", { image: "nginx:alpine", context: remote });
|
|
111
|
+
* ```
|
|
112
|
+
*
|
|
92
113
|
* @resource
|
|
93
114
|
* @product Context
|
|
94
115
|
*/
|
|
@@ -107,6 +128,11 @@ export const ContextProvider = () =>
|
|
|
107
128
|
|
|
108
129
|
return Context.Provider.of({
|
|
109
130
|
list: () => Effect.succeed([]),
|
|
131
|
+
lookup: Effect.fn(function* ({ name }) {
|
|
132
|
+
const live = yield* inspect(name);
|
|
133
|
+
return live ? toContextAttributes(live) : undefined;
|
|
134
|
+
}),
|
|
135
|
+
|
|
110
136
|
read: Effect.fn(function* ({ id, instanceId, olds, output }) {
|
|
111
137
|
const name = yield* dockerPhysicalName(id, olds, instanceId);
|
|
112
138
|
const live = yield* inspect(name);
|
package/src/Docker.ts
CHANGED
|
@@ -271,7 +271,26 @@ export class Docker extends Context.Service<
|
|
|
271
271
|
readonly create: (options: {
|
|
272
272
|
name: string;
|
|
273
273
|
driver: string;
|
|
274
|
+
/** Whether the network is isolated from external connectivity. */
|
|
275
|
+
internal?: boolean;
|
|
276
|
+
/** Whether standalone containers may attach to the network. */
|
|
277
|
+
attachable?: boolean;
|
|
278
|
+
/** Explicitly enable or disable IPv4 address allocation. */
|
|
279
|
+
ipv4?: boolean;
|
|
274
280
|
ipv6?: boolean;
|
|
281
|
+
/** Network driver options, passed as repeated `--opt` arguments. */
|
|
282
|
+
opt?: Record<string, string>;
|
|
283
|
+
/** Network IP Address Management settings. */
|
|
284
|
+
ipam?: {
|
|
285
|
+
driver?: string;
|
|
286
|
+
options?: Record<string, string>;
|
|
287
|
+
config?: Array<{
|
|
288
|
+
subnet: string;
|
|
289
|
+
gateway?: string;
|
|
290
|
+
ipRange?: string;
|
|
291
|
+
auxAddresses?: Record<string, string>;
|
|
292
|
+
}>;
|
|
293
|
+
};
|
|
275
294
|
label?: Record<string, string>;
|
|
276
295
|
context?: string;
|
|
277
296
|
}) => Effect.Effect<CommandOutput, PlatformError>;
|
|
@@ -555,7 +574,21 @@ export declare namespace Docker {
|
|
|
555
574
|
Created: string;
|
|
556
575
|
Scope: string;
|
|
557
576
|
Driver: string;
|
|
577
|
+
Internal?: boolean;
|
|
578
|
+
Attachable?: boolean;
|
|
579
|
+
EnableIPv4?: boolean;
|
|
558
580
|
EnableIPv6: boolean;
|
|
581
|
+
Options?: Record<string, string> | null;
|
|
582
|
+
IPAM?: {
|
|
583
|
+
Driver?: string;
|
|
584
|
+
Options?: Record<string, string> | null;
|
|
585
|
+
Config?: Array<{
|
|
586
|
+
Subnet: string;
|
|
587
|
+
Gateway?: string;
|
|
588
|
+
IPRange?: string;
|
|
589
|
+
AuxiliaryAddresses?: Record<string, string> | null;
|
|
590
|
+
}> | null;
|
|
591
|
+
};
|
|
559
592
|
Labels: Record<string, string> | null;
|
|
560
593
|
}
|
|
561
594
|
}
|
|
@@ -1000,13 +1033,34 @@ const makeDocker = (options: DockerOptions) =>
|
|
|
1000
1033
|
remove: (name, force) => run(["context", "rm", ...(force ? ["-f"] : []), name]),
|
|
1001
1034
|
},
|
|
1002
1035
|
network: {
|
|
1003
|
-
create: ({ name, driver, ipv6, label, context }) =>
|
|
1036
|
+
create: ({ name, driver, internal, attachable, ipv4, ipv6, opt, ipam, label, context }) =>
|
|
1004
1037
|
run([
|
|
1005
1038
|
...formatArgs({ context }),
|
|
1006
1039
|
"network",
|
|
1007
1040
|
"create",
|
|
1041
|
+
...formatArgs({
|
|
1042
|
+
driver,
|
|
1043
|
+
internal,
|
|
1044
|
+
attachable,
|
|
1045
|
+
ipv6,
|
|
1046
|
+
opt,
|
|
1047
|
+
"ipam-driver": ipam?.driver,
|
|
1048
|
+
"ipam-opt": ipam?.options,
|
|
1049
|
+
label,
|
|
1050
|
+
}),
|
|
1051
|
+
// Docker's boolean --ipv4=false needs an equals sign; the generic
|
|
1052
|
+
// CLI formatter intentionally skips false values elsewhere.
|
|
1053
|
+
...(ipv4 === undefined ? [] : [`--ipv4=` + String(ipv4)]),
|
|
1054
|
+
...(ipam?.config ?? []).flatMap(({ subnet, gateway, ipRange, auxAddresses }) => [
|
|
1055
|
+
"--subnet",
|
|
1056
|
+
subnet,
|
|
1057
|
+
...(gateway === undefined ? [] : ["--gateway", gateway]),
|
|
1058
|
+
...(ipRange === undefined ? [] : ["--ip-range", ipRange]),
|
|
1059
|
+
...Object.entries(auxAddresses ?? {})
|
|
1060
|
+
.sort(([a], [b]) => a.localeCompare(b))
|
|
1061
|
+
.flatMap(([key, value]) => ["--aux-address", key + "=" + value]),
|
|
1062
|
+
]),
|
|
1008
1063
|
name,
|
|
1009
|
-
...formatArgs({ driver, ipv6, label }),
|
|
1010
1064
|
]),
|
|
1011
1065
|
connect: ({ network, container, alias, context }) =>
|
|
1012
1066
|
run([
|
package/src/Dockerfile.ts
CHANGED
|
@@ -20,7 +20,6 @@
|
|
|
20
20
|
* const worker = yield* AWS.ECS.Task(
|
|
21
21
|
* "Transcoder",
|
|
22
22
|
* {
|
|
23
|
-
* cluster,
|
|
24
23
|
* main: import.meta.url,
|
|
25
24
|
* dockerfile: Dockerfile.inline`
|
|
26
25
|
* FROM oven/bun:1
|
|
@@ -38,7 +37,6 @@
|
|
|
38
37
|
* const trainer = yield* AWS.ECS.Task(
|
|
39
38
|
* "Trainer",
|
|
40
39
|
* {
|
|
41
|
-
* cluster,
|
|
42
40
|
* main: import.meta.url,
|
|
43
41
|
* dockerfile: Dockerfile.inline`
|
|
44
42
|
* FROM ${base.imageUri}
|