@dagger.io/dagger 0.3.4 → 0.3.5
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/api/client.gen.js
CHANGED
|
@@ -53,6 +53,20 @@ export var CacheSharingMode;
|
|
|
53
53
|
*/
|
|
54
54
|
CacheSharingMode[CacheSharingMode["Shared"] = 2] = "Shared";
|
|
55
55
|
})(CacheSharingMode || (CacheSharingMode = {}));
|
|
56
|
+
/**
|
|
57
|
+
* Transport layer network protocol associated to a port.
|
|
58
|
+
*/
|
|
59
|
+
export var NetworkProtocol;
|
|
60
|
+
(function (NetworkProtocol) {
|
|
61
|
+
/**
|
|
62
|
+
* TCP (Transmission Control Protocol)
|
|
63
|
+
*/
|
|
64
|
+
NetworkProtocol[NetworkProtocol["Tcp"] = 0] = "Tcp";
|
|
65
|
+
/**
|
|
66
|
+
* UDP (User Datagram Protocol)
|
|
67
|
+
*/
|
|
68
|
+
NetworkProtocol[NetworkProtocol["Udp"] = 1] = "Udp";
|
|
69
|
+
})(NetworkProtocol || (NetworkProtocol = {}));
|
|
56
70
|
/**
|
|
57
71
|
* A directory whose contents persist across runs.
|
|
58
72
|
*/
|
|
@@ -98,10 +112,11 @@ export class CacheVolume extends BaseClient {
|
|
|
98
112
|
*/
|
|
99
113
|
export class Container extends BaseClient {
|
|
100
114
|
/**
|
|
101
|
-
* Initializes this container from a Dockerfile build
|
|
115
|
+
* Initializes this container from a Dockerfile build.
|
|
102
116
|
* @param context Directory context used by the Dockerfile.
|
|
103
117
|
* @param opts.dockerfile Path to the Dockerfile to use.
|
|
104
|
-
|
|
118
|
+
*
|
|
119
|
+
* Default: './Dockerfile'.
|
|
105
120
|
* @param opts.buildArgs Additional build arguments.
|
|
106
121
|
* @param opts.target Target build stage to build.
|
|
107
122
|
*/
|
|
@@ -133,7 +148,10 @@ export class Container extends BaseClient {
|
|
|
133
148
|
});
|
|
134
149
|
}
|
|
135
150
|
/**
|
|
136
|
-
* Retrieves a directory at the given path.
|
|
151
|
+
* Retrieves a directory at the given path.
|
|
152
|
+
*
|
|
153
|
+
* Mounts are included.
|
|
154
|
+
* @param path The path of the directory to retrieve (e.g., "./src").
|
|
137
155
|
*/
|
|
138
156
|
directory(path) {
|
|
139
157
|
return new Directory({
|
|
@@ -148,6 +166,27 @@ export class Container extends BaseClient {
|
|
|
148
166
|
sessionToken: this.sessionToken,
|
|
149
167
|
});
|
|
150
168
|
}
|
|
169
|
+
/**
|
|
170
|
+
* Retrieves an endpoint that clients can use to reach this container.
|
|
171
|
+
*
|
|
172
|
+
* If no port is specified, the first exposed port is used. If none exist an error is returned.
|
|
173
|
+
*
|
|
174
|
+
* If a scheme is specified, a URL is returned. Otherwise, a host:port pair is returned.
|
|
175
|
+
* @param opts.port The exposed port number for the endpoint
|
|
176
|
+
* @param opts.scheme Return a URL with the given scheme, eg. http for http://
|
|
177
|
+
*/
|
|
178
|
+
endpoint(opts) {
|
|
179
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
180
|
+
const response = yield computeQuery([
|
|
181
|
+
...this._queryTree,
|
|
182
|
+
{
|
|
183
|
+
operation: "endpoint",
|
|
184
|
+
args: Object.assign({}, opts),
|
|
185
|
+
},
|
|
186
|
+
], this.client);
|
|
187
|
+
return response;
|
|
188
|
+
});
|
|
189
|
+
}
|
|
151
190
|
/**
|
|
152
191
|
* Retrieves entrypoint to be prepended to the arguments of all commands.
|
|
153
192
|
*/
|
|
@@ -164,6 +203,7 @@ export class Container extends BaseClient {
|
|
|
164
203
|
}
|
|
165
204
|
/**
|
|
166
205
|
* Retrieves the value of the specified environment variable.
|
|
206
|
+
* @param name The name of the environment variable to retrieve (e.g., "PATH").
|
|
167
207
|
*/
|
|
168
208
|
envVariable(name) {
|
|
169
209
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -193,13 +233,13 @@ export class Container extends BaseClient {
|
|
|
193
233
|
}
|
|
194
234
|
/**
|
|
195
235
|
* Retrieves this container after executing the specified command inside it.
|
|
196
|
-
* @param opts.args Command to run instead of the container's default command.
|
|
197
|
-
* @param opts.stdin Content to write to the command's standard input before closing.
|
|
198
|
-
* @param opts.redirectStdout Redirect the command's standard output to a file in the container.
|
|
199
|
-
* @param opts.redirectStderr Redirect the command's standard error to a file in the container.
|
|
236
|
+
* @param opts.args Command to run instead of the container's default command (e.g., ["run", "main.go"]).
|
|
237
|
+
* @param opts.stdin Content to write to the command's standard input before closing (e.g., "Hello world").
|
|
238
|
+
* @param opts.redirectStdout Redirect the command's standard output to a file in the container (e.g., "/tmp/stdout").
|
|
239
|
+
* @param opts.redirectStderr Redirect the command's standard error to a file in the container (e.g., "/tmp/stderr").
|
|
200
240
|
* @param opts.experimentalPrivilegedNesting Provide dagger access to the executed command.
|
|
201
|
-
|
|
202
|
-
|
|
241
|
+
* Do not use this option unless you trust the command being executed.
|
|
242
|
+
* The command being executed WILL BE GRANTED FULL ACCESS TO YOUR HOST FILESYSTEM.
|
|
203
243
|
* @deprecated Replaced by withExec.
|
|
204
244
|
*/
|
|
205
245
|
exec(opts) {
|
|
@@ -231,12 +271,14 @@ export class Container extends BaseClient {
|
|
|
231
271
|
});
|
|
232
272
|
}
|
|
233
273
|
/**
|
|
234
|
-
* Writes the container as an OCI tarball to the destination file path on the host for the specified
|
|
274
|
+
* Writes the container as an OCI tarball to the destination file path on the host for the specified platform variants.
|
|
275
|
+
*
|
|
235
276
|
* Return true on success.
|
|
236
|
-
*
|
|
237
|
-
|
|
277
|
+
* It can also publishes platform variants.
|
|
278
|
+
* @param path Host's destination path (e.g., "./tarball").
|
|
279
|
+
* Path can be relative to the engine's workdir or absolute.
|
|
238
280
|
* @param opts.platformVariants Identifiers for other platform specific containers.
|
|
239
|
-
|
|
281
|
+
* Used for multi-platform image.
|
|
240
282
|
*/
|
|
241
283
|
export(path, opts) {
|
|
242
284
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -251,7 +293,24 @@ export class Container extends BaseClient {
|
|
|
251
293
|
});
|
|
252
294
|
}
|
|
253
295
|
/**
|
|
254
|
-
* Retrieves
|
|
296
|
+
* Retrieves the list of exposed ports
|
|
297
|
+
*/
|
|
298
|
+
exposedPorts() {
|
|
299
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
300
|
+
const response = yield computeQuery([
|
|
301
|
+
...this._queryTree,
|
|
302
|
+
{
|
|
303
|
+
operation: "exposedPorts",
|
|
304
|
+
},
|
|
305
|
+
], this.client);
|
|
306
|
+
return response;
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* Retrieves a file at the given path.
|
|
311
|
+
*
|
|
312
|
+
* Mounts are included.
|
|
313
|
+
* @param path The path of the file to retrieve (e.g., "./README.md").
|
|
255
314
|
*/
|
|
256
315
|
file(path) {
|
|
257
316
|
return new File({
|
|
@@ -267,9 +326,10 @@ export class Container extends BaseClient {
|
|
|
267
326
|
});
|
|
268
327
|
}
|
|
269
328
|
/**
|
|
270
|
-
* Initializes this container from
|
|
329
|
+
* Initializes this container from a pulled base image.
|
|
271
330
|
* @param address Image's address from its registry.
|
|
272
|
-
|
|
331
|
+
*
|
|
332
|
+
* Formatted as [host]/[user]/[repo]:[tag] (e.g., "docker.io/dagger/dagger:main").
|
|
273
333
|
*/
|
|
274
334
|
from(address) {
|
|
275
335
|
return new Container({
|
|
@@ -300,6 +360,20 @@ export class Container extends BaseClient {
|
|
|
300
360
|
sessionToken: this.sessionToken,
|
|
301
361
|
});
|
|
302
362
|
}
|
|
363
|
+
/**
|
|
364
|
+
* Retrieves a hostname which can be used by clients to reach this container.
|
|
365
|
+
*/
|
|
366
|
+
hostname() {
|
|
367
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
368
|
+
const response = yield computeQuery([
|
|
369
|
+
...this._queryTree,
|
|
370
|
+
{
|
|
371
|
+
operation: "hostname",
|
|
372
|
+
},
|
|
373
|
+
], this.client);
|
|
374
|
+
return response;
|
|
375
|
+
});
|
|
376
|
+
}
|
|
303
377
|
/**
|
|
304
378
|
* A unique identifier for this container.
|
|
305
379
|
*/
|
|
@@ -314,6 +388,20 @@ export class Container extends BaseClient {
|
|
|
314
388
|
return response;
|
|
315
389
|
});
|
|
316
390
|
}
|
|
391
|
+
/**
|
|
392
|
+
* The unique image reference which can only be retrieved immediately after the 'Container.From' call.
|
|
393
|
+
*/
|
|
394
|
+
imageRef() {
|
|
395
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
396
|
+
const response = yield computeQuery([
|
|
397
|
+
...this._queryTree,
|
|
398
|
+
{
|
|
399
|
+
operation: "imageRef",
|
|
400
|
+
},
|
|
401
|
+
], this.client);
|
|
402
|
+
return response;
|
|
403
|
+
});
|
|
404
|
+
}
|
|
317
405
|
/**
|
|
318
406
|
* Retrieves the value of the specified label.
|
|
319
407
|
*/
|
|
@@ -388,11 +476,15 @@ export class Container extends BaseClient {
|
|
|
388
476
|
});
|
|
389
477
|
}
|
|
390
478
|
/**
|
|
391
|
-
* Publishes this container as a new image to the specified address
|
|
479
|
+
* Publishes this container as a new image to the specified address.
|
|
480
|
+
*
|
|
481
|
+
* Publish returns a fully qualified ref.
|
|
482
|
+
* It can also publish platform variants.
|
|
392
483
|
* @param address Registry's address to publish the image to.
|
|
393
|
-
|
|
484
|
+
*
|
|
485
|
+
* Formatted as [host]/[user]/[repo]:[tag] (e.g. "docker.io/dagger/dagger:main").
|
|
394
486
|
* @param opts.platformVariants Identifiers for other platform specific containers.
|
|
395
|
-
|
|
487
|
+
* Used for multi-platform image.
|
|
396
488
|
*/
|
|
397
489
|
publish(address, opts) {
|
|
398
490
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -467,6 +559,7 @@ export class Container extends BaseClient {
|
|
|
467
559
|
}
|
|
468
560
|
/**
|
|
469
561
|
* Configures default arguments for future commands.
|
|
562
|
+
* @param opts.args Arguments to prepend to future executions (e.g., ["-v", "--no-cache"]).
|
|
470
563
|
*/
|
|
471
564
|
withDefaultArgs(opts) {
|
|
472
565
|
return new Container({
|
|
@@ -483,6 +576,10 @@ export class Container extends BaseClient {
|
|
|
483
576
|
}
|
|
484
577
|
/**
|
|
485
578
|
* Retrieves this container plus a directory written at the given path.
|
|
579
|
+
* @param path Location of the written directory (e.g., "/tmp/directory").
|
|
580
|
+
* @param directory Identifier of the directory to write
|
|
581
|
+
* @param opts.exclude Patterns to exclude in the written directory (e.g., ["node_modules/**", ".gitignore", ".git/"]).
|
|
582
|
+
* @param opts.include Patterns to include in the written directory (e.g., ["*.go", "go.mod", "go.sum"]).
|
|
486
583
|
*/
|
|
487
584
|
withDirectory(path, directory, opts) {
|
|
488
585
|
return new Container({
|
|
@@ -499,6 +596,7 @@ export class Container extends BaseClient {
|
|
|
499
596
|
}
|
|
500
597
|
/**
|
|
501
598
|
* Retrieves this container but with a different command entrypoint.
|
|
599
|
+
* @param args Entrypoint to use for future executions (e.g., ["go", "run"]).
|
|
502
600
|
*/
|
|
503
601
|
withEntrypoint(args) {
|
|
504
602
|
return new Container({
|
|
@@ -515,6 +613,8 @@ export class Container extends BaseClient {
|
|
|
515
613
|
}
|
|
516
614
|
/**
|
|
517
615
|
* Retrieves this container plus the given environment variable.
|
|
616
|
+
* @param name The name of the environment variable (e.g., "HOST").
|
|
617
|
+
* @param value The value of the environment variable. (e.g., "localhost").
|
|
518
618
|
*/
|
|
519
619
|
withEnvVariable(name, value) {
|
|
520
620
|
return new Container({
|
|
@@ -531,13 +631,14 @@ export class Container extends BaseClient {
|
|
|
531
631
|
}
|
|
532
632
|
/**
|
|
533
633
|
* Retrieves this container after executing the specified command inside it.
|
|
534
|
-
* @param args Command to run instead of the container's default command.
|
|
535
|
-
* @param opts.stdin Content to write to the command's standard input before closing.
|
|
536
|
-
* @param opts.redirectStdout Redirect the command's standard output to a file in the container.
|
|
537
|
-
* @param opts.redirectStderr Redirect the command's standard error to a file in the container.
|
|
538
|
-
* @param opts.experimentalPrivilegedNesting
|
|
539
|
-
|
|
540
|
-
|
|
634
|
+
* @param args Command to run instead of the container's default command (e.g., ["run", "main.go"]).
|
|
635
|
+
* @param opts.stdin Content to write to the command's standard input before closing (e.g., "Hello world").
|
|
636
|
+
* @param opts.redirectStdout Redirect the command's standard output to a file in the container (e.g., "/tmp/stdout").
|
|
637
|
+
* @param opts.redirectStderr Redirect the command's standard error to a file in the container (e.g., "/tmp/stderr").
|
|
638
|
+
* @param opts.experimentalPrivilegedNesting Provides dagger access to the executed command.
|
|
639
|
+
*
|
|
640
|
+
* Do not use this option unless you trust the command being executed.
|
|
641
|
+
* The command being executed WILL BE GRANTED FULL ACCESS TO YOUR HOST FILESYSTEM.
|
|
541
642
|
*/
|
|
542
643
|
withExec(args, opts) {
|
|
543
644
|
return new Container({
|
|
@@ -552,6 +653,28 @@ export class Container extends BaseClient {
|
|
|
552
653
|
sessionToken: this.sessionToken,
|
|
553
654
|
});
|
|
554
655
|
}
|
|
656
|
+
/**
|
|
657
|
+
* Expose a network port.
|
|
658
|
+
* Exposed ports serve two purposes:
|
|
659
|
+
* - For health checks and introspection, when running services
|
|
660
|
+
* - For setting the EXPOSE OCI field when publishing the container
|
|
661
|
+
* @param port Port number to expose
|
|
662
|
+
* @param opts.protocol Transport layer network protocol
|
|
663
|
+
* @param opts.description Optional port description
|
|
664
|
+
*/
|
|
665
|
+
withExposedPort(port, opts) {
|
|
666
|
+
return new Container({
|
|
667
|
+
queryTree: [
|
|
668
|
+
...this._queryTree,
|
|
669
|
+
{
|
|
670
|
+
operation: "withExposedPort",
|
|
671
|
+
args: Object.assign({ port }, opts),
|
|
672
|
+
},
|
|
673
|
+
],
|
|
674
|
+
host: this.clientHost,
|
|
675
|
+
sessionToken: this.sessionToken,
|
|
676
|
+
});
|
|
677
|
+
}
|
|
555
678
|
/**
|
|
556
679
|
* Initializes this container from this DirectoryID.
|
|
557
680
|
* @deprecated Replaced by withRootfs.
|
|
@@ -571,6 +694,11 @@ export class Container extends BaseClient {
|
|
|
571
694
|
}
|
|
572
695
|
/**
|
|
573
696
|
* Retrieves this container plus the contents of the given file copied to the given path.
|
|
697
|
+
* @param path Location of the copied file (e.g., "/tmp/file.txt").
|
|
698
|
+
* @param source Identifier of the file to copy.
|
|
699
|
+
* @param opts.permissions Permission given to the copied file (e.g., 0600).
|
|
700
|
+
*
|
|
701
|
+
* Default: 0644.
|
|
574
702
|
*/
|
|
575
703
|
withFile(path, source, opts) {
|
|
576
704
|
return new Container({
|
|
@@ -587,6 +715,8 @@ export class Container extends BaseClient {
|
|
|
587
715
|
}
|
|
588
716
|
/**
|
|
589
717
|
* Retrieves this container plus the given label.
|
|
718
|
+
* @param name The name of the label (e.g., "org.opencontainers.artifact.created").
|
|
719
|
+
* @param value The value of the label (e.g., "2023-01-01T00:00:00Z").
|
|
590
720
|
*/
|
|
591
721
|
withLabel(name, value) {
|
|
592
722
|
return new Container({
|
|
@@ -603,9 +733,9 @@ export class Container extends BaseClient {
|
|
|
603
733
|
}
|
|
604
734
|
/**
|
|
605
735
|
* Retrieves this container plus a cache volume mounted at the given path.
|
|
606
|
-
* @param path
|
|
607
|
-
* @param cache
|
|
608
|
-
* @param opts.source
|
|
736
|
+
* @param path Location of the cache directory (e.g., "/cache/node_modules").
|
|
737
|
+
* @param cache Identifier of the cache volume to mount.
|
|
738
|
+
* @param opts.source Identifier of the directory to use as the cache volume's root.
|
|
609
739
|
* @param opts.sharing Sharing mode of the cache volume.
|
|
610
740
|
*/
|
|
611
741
|
withMountedCache(path, cache, opts) {
|
|
@@ -623,6 +753,8 @@ export class Container extends BaseClient {
|
|
|
623
753
|
}
|
|
624
754
|
/**
|
|
625
755
|
* Retrieves this container plus a directory mounted at the given path.
|
|
756
|
+
* @param path Location of the mounted directory (e.g., "/mnt/directory").
|
|
757
|
+
* @param source Identifier of the mounted directory.
|
|
626
758
|
*/
|
|
627
759
|
withMountedDirectory(path, source) {
|
|
628
760
|
return new Container({
|
|
@@ -639,6 +771,8 @@ export class Container extends BaseClient {
|
|
|
639
771
|
}
|
|
640
772
|
/**
|
|
641
773
|
* Retrieves this container plus a file mounted at the given path.
|
|
774
|
+
* @param path Location of the mounted file (e.g., "/tmp/file.txt").
|
|
775
|
+
* @param source Identifier of the mounted file.
|
|
642
776
|
*/
|
|
643
777
|
withMountedFile(path, source) {
|
|
644
778
|
return new Container({
|
|
@@ -655,6 +789,8 @@ export class Container extends BaseClient {
|
|
|
655
789
|
}
|
|
656
790
|
/**
|
|
657
791
|
* Retrieves this container plus a secret mounted into a file at the given path.
|
|
792
|
+
* @param path Location of the secret file (e.g., "/tmp/secret.txt").
|
|
793
|
+
* @param source Identifier of the secret to mount.
|
|
658
794
|
*/
|
|
659
795
|
withMountedSecret(path, source) {
|
|
660
796
|
return new Container({
|
|
@@ -671,6 +807,7 @@ export class Container extends BaseClient {
|
|
|
671
807
|
}
|
|
672
808
|
/**
|
|
673
809
|
* Retrieves this container plus a temporary directory mounted at the given path.
|
|
810
|
+
* @param path Location of the temporary directory (e.g., "/tmp/temp_dir").
|
|
674
811
|
*/
|
|
675
812
|
withMountedTemp(path) {
|
|
676
813
|
return new Container({
|
|
@@ -687,6 +824,11 @@ export class Container extends BaseClient {
|
|
|
687
824
|
}
|
|
688
825
|
/**
|
|
689
826
|
* Retrieves this container plus a new file written at the given path.
|
|
827
|
+
* @param path Location of the written file (e.g., "/tmp/file.txt").
|
|
828
|
+
* @param opts.contents Content of the file to write (e.g., "Hello world!").
|
|
829
|
+
* @param opts.permissions Permission given to the written file (e.g., 0600).
|
|
830
|
+
*
|
|
831
|
+
* Default: 0644.
|
|
690
832
|
*/
|
|
691
833
|
withNewFile(path, opts) {
|
|
692
834
|
return new Container({
|
|
@@ -704,7 +846,7 @@ export class Container extends BaseClient {
|
|
|
704
846
|
/**
|
|
705
847
|
* Retrieves this container with a registry authentication for a given address.
|
|
706
848
|
* @param address Registry's address to bind the authentication to.
|
|
707
|
-
|
|
849
|
+
* Formatted as [host]/[user]/[repo]:[tag] (e.g. docker.io/dagger/dagger:main).
|
|
708
850
|
* @param username The username of the registry's account (e.g., "Dagger").
|
|
709
851
|
* @param secret The API key, password or token to authenticate to this registry.
|
|
710
852
|
*/
|
|
@@ -739,6 +881,8 @@ export class Container extends BaseClient {
|
|
|
739
881
|
}
|
|
740
882
|
/**
|
|
741
883
|
* Retrieves this container plus an env variable containing the given secret.
|
|
884
|
+
* @param name The name of the secret variable (e.g., "API_SECRET").
|
|
885
|
+
* @param secret The identifier of the secret value.
|
|
742
886
|
*/
|
|
743
887
|
withSecretVariable(name, secret) {
|
|
744
888
|
return new Container({
|
|
@@ -753,8 +897,32 @@ export class Container extends BaseClient {
|
|
|
753
897
|
sessionToken: this.sessionToken,
|
|
754
898
|
});
|
|
755
899
|
}
|
|
900
|
+
/**
|
|
901
|
+
* Establish a runtime dependency on a service. The service will be started automatically when needed and detached when it is no longer needed.
|
|
902
|
+
*
|
|
903
|
+
* The service will be reachable from the container via the provided hostname alias.
|
|
904
|
+
*
|
|
905
|
+
* The service dependency will also convey to any files or directories produced by the container.
|
|
906
|
+
* @param alias A name that can be used to reach the service from the container
|
|
907
|
+
* @param service Identifier of the service container
|
|
908
|
+
*/
|
|
909
|
+
withServiceBinding(alias, service) {
|
|
910
|
+
return new Container({
|
|
911
|
+
queryTree: [
|
|
912
|
+
...this._queryTree,
|
|
913
|
+
{
|
|
914
|
+
operation: "withServiceBinding",
|
|
915
|
+
args: { alias, service },
|
|
916
|
+
},
|
|
917
|
+
],
|
|
918
|
+
host: this.clientHost,
|
|
919
|
+
sessionToken: this.sessionToken,
|
|
920
|
+
});
|
|
921
|
+
}
|
|
756
922
|
/**
|
|
757
923
|
* Retrieves this container plus a socket forwarded to the given Unix socket path.
|
|
924
|
+
* @param path Location of the forwarded Unix socket (e.g., "/tmp/socket").
|
|
925
|
+
* @param source Identifier of the socket to forward.
|
|
758
926
|
*/
|
|
759
927
|
withUnixSocket(path, source) {
|
|
760
928
|
return new Container({
|
|
@@ -770,7 +938,8 @@ export class Container extends BaseClient {
|
|
|
770
938
|
});
|
|
771
939
|
}
|
|
772
940
|
/**
|
|
773
|
-
* Retrieves this
|
|
941
|
+
* Retrieves this container with a different command user.
|
|
942
|
+
* @param name The user to set (e.g., "root").
|
|
774
943
|
*/
|
|
775
944
|
withUser(name) {
|
|
776
945
|
return new Container({
|
|
@@ -787,6 +956,7 @@ export class Container extends BaseClient {
|
|
|
787
956
|
}
|
|
788
957
|
/**
|
|
789
958
|
* Retrieves this container with a different working directory.
|
|
959
|
+
* @param path The path to set as the working directory (e.g., "/app").
|
|
790
960
|
*/
|
|
791
961
|
withWorkdir(path) {
|
|
792
962
|
return new Container({
|
|
@@ -803,6 +973,7 @@ export class Container extends BaseClient {
|
|
|
803
973
|
}
|
|
804
974
|
/**
|
|
805
975
|
* Retrieves this container minus the given environment variable.
|
|
976
|
+
* @param name The name of the environment variable (e.g., "HOST").
|
|
806
977
|
*/
|
|
807
978
|
withoutEnvVariable(name) {
|
|
808
979
|
return new Container({
|
|
@@ -817,8 +988,27 @@ export class Container extends BaseClient {
|
|
|
817
988
|
sessionToken: this.sessionToken,
|
|
818
989
|
});
|
|
819
990
|
}
|
|
991
|
+
/**
|
|
992
|
+
* Unexpose a previously exposed port.
|
|
993
|
+
* @param port Port number to unexpose
|
|
994
|
+
* @param opts.protocol Port protocol to unexpose
|
|
995
|
+
*/
|
|
996
|
+
withoutExposedPort(port, opts) {
|
|
997
|
+
return new Container({
|
|
998
|
+
queryTree: [
|
|
999
|
+
...this._queryTree,
|
|
1000
|
+
{
|
|
1001
|
+
operation: "withoutExposedPort",
|
|
1002
|
+
args: Object.assign({ port }, opts),
|
|
1003
|
+
},
|
|
1004
|
+
],
|
|
1005
|
+
host: this.clientHost,
|
|
1006
|
+
sessionToken: this.sessionToken,
|
|
1007
|
+
});
|
|
1008
|
+
}
|
|
820
1009
|
/**
|
|
821
1010
|
* Retrieves this container minus the given environment label.
|
|
1011
|
+
* @param name The name of the label to remove (e.g., "org.opencontainers.artifact.created").
|
|
822
1012
|
*/
|
|
823
1013
|
withoutLabel(name) {
|
|
824
1014
|
return new Container({
|
|
@@ -835,6 +1025,7 @@ export class Container extends BaseClient {
|
|
|
835
1025
|
}
|
|
836
1026
|
/**
|
|
837
1027
|
* Retrieves this container after unmounting everything at the given path.
|
|
1028
|
+
* @param path Location of the cache directory (e.g., "/cache/node_modules").
|
|
838
1029
|
*/
|
|
839
1030
|
withoutMount(path) {
|
|
840
1031
|
return new Container({
|
|
@@ -852,7 +1043,7 @@ export class Container extends BaseClient {
|
|
|
852
1043
|
/**
|
|
853
1044
|
* Retrieves this container without the registry authentication of a given address.
|
|
854
1045
|
* @param address Registry's address to remove the authentication from.
|
|
855
|
-
|
|
1046
|
+
* Formatted as [host]/[user]/[repo]:[tag] (e.g. docker.io/dagger/dagger:main).
|
|
856
1047
|
*/
|
|
857
1048
|
withoutRegistryAuth(address) {
|
|
858
1049
|
return new Container({
|
|
@@ -869,6 +1060,7 @@ export class Container extends BaseClient {
|
|
|
869
1060
|
}
|
|
870
1061
|
/**
|
|
871
1062
|
* Retrieves this container with a previously added Unix socket removed.
|
|
1063
|
+
* @param path Location of the socket to remove (e.g., "/tmp/socket").
|
|
872
1064
|
*/
|
|
873
1065
|
withoutUnixSocket(path) {
|
|
874
1066
|
return new Container({
|
|
@@ -928,6 +1120,7 @@ export class Container extends BaseClient {
|
|
|
928
1120
|
export class Directory extends BaseClient {
|
|
929
1121
|
/**
|
|
930
1122
|
* Gets the difference between this directory and an another directory.
|
|
1123
|
+
* @param other Identifier of the directory to compare.
|
|
931
1124
|
*/
|
|
932
1125
|
diff(other) {
|
|
933
1126
|
return new Directory({
|
|
@@ -944,6 +1137,7 @@ export class Directory extends BaseClient {
|
|
|
944
1137
|
}
|
|
945
1138
|
/**
|
|
946
1139
|
* Retrieves a directory at the given path.
|
|
1140
|
+
* @param path Location of the directory to retrieve (e.g., "/src").
|
|
947
1141
|
*/
|
|
948
1142
|
directory(path) {
|
|
949
1143
|
return new Directory({
|
|
@@ -960,10 +1154,11 @@ export class Directory extends BaseClient {
|
|
|
960
1154
|
}
|
|
961
1155
|
/**
|
|
962
1156
|
* Builds a new Docker container from this directory.
|
|
963
|
-
* @param opts.dockerfile Path to the Dockerfile to use.
|
|
964
|
-
|
|
1157
|
+
* @param opts.dockerfile Path to the Dockerfile to use (e.g., "frontend.Dockerfile").
|
|
1158
|
+
*
|
|
1159
|
+
* Defaults: './Dockerfile'.
|
|
965
1160
|
* @param opts.platform The platform to build.
|
|
966
|
-
* @param opts.buildArgs
|
|
1161
|
+
* @param opts.buildArgs Build arguments to use in the build.
|
|
967
1162
|
* @param opts.target Target build stage to build.
|
|
968
1163
|
*/
|
|
969
1164
|
dockerBuild(opts) {
|
|
@@ -981,6 +1176,7 @@ export class Directory extends BaseClient {
|
|
|
981
1176
|
}
|
|
982
1177
|
/**
|
|
983
1178
|
* Returns a list of files and directories at the given path.
|
|
1179
|
+
* @param opts.path Location of the directory to look at (e.g., "/src").
|
|
984
1180
|
*/
|
|
985
1181
|
entries(opts) {
|
|
986
1182
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -996,6 +1192,7 @@ export class Directory extends BaseClient {
|
|
|
996
1192
|
}
|
|
997
1193
|
/**
|
|
998
1194
|
* Writes the contents of the directory to a path on the host.
|
|
1195
|
+
* @param path Location of the copied directory (e.g., "logs/").
|
|
999
1196
|
*/
|
|
1000
1197
|
export(path) {
|
|
1001
1198
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -1011,6 +1208,7 @@ export class Directory extends BaseClient {
|
|
|
1011
1208
|
}
|
|
1012
1209
|
/**
|
|
1013
1210
|
* Retrieves a file at the given path.
|
|
1211
|
+
* @param path Location of the file to retrieve (e.g., "README.md").
|
|
1014
1212
|
*/
|
|
1015
1213
|
file(path) {
|
|
1016
1214
|
return new File({
|
|
@@ -1073,10 +1271,10 @@ export class Directory extends BaseClient {
|
|
|
1073
1271
|
}
|
|
1074
1272
|
/**
|
|
1075
1273
|
* Retrieves this directory plus a directory written at the given path.
|
|
1076
|
-
* @param
|
|
1077
|
-
|
|
1078
|
-
* @param opts.
|
|
1079
|
-
|
|
1274
|
+
* @param path Location of the written directory (e.g., "/src/").
|
|
1275
|
+
* @param directory Identifier of the directory to copy.
|
|
1276
|
+
* @param opts.exclude Exclude artifacts that match the given pattern (e.g., ["node_modules/", ".git*"]).
|
|
1277
|
+
* @param opts.include Include only artifacts that match the given pattern (e.g., ["app/", "package.*"]).
|
|
1080
1278
|
*/
|
|
1081
1279
|
withDirectory(path, directory, opts) {
|
|
1082
1280
|
return new Directory({
|
|
@@ -1093,6 +1291,11 @@ export class Directory extends BaseClient {
|
|
|
1093
1291
|
}
|
|
1094
1292
|
/**
|
|
1095
1293
|
* Retrieves this directory plus the contents of the given file copied to the given path.
|
|
1294
|
+
* @param path Location of the copied file (e.g., "/file.txt").
|
|
1295
|
+
* @param source Identifier of the file to copy.
|
|
1296
|
+
* @param opts.permissions Permission given to the copied file (e.g., 0600).
|
|
1297
|
+
*
|
|
1298
|
+
* Default: 0644.
|
|
1096
1299
|
*/
|
|
1097
1300
|
withFile(path, source, opts) {
|
|
1098
1301
|
return new Directory({
|
|
@@ -1109,6 +1312,10 @@ export class Directory extends BaseClient {
|
|
|
1109
1312
|
}
|
|
1110
1313
|
/**
|
|
1111
1314
|
* Retrieves this directory plus a new directory created at the given path.
|
|
1315
|
+
* @param path Location of the directory created (e.g., "/logs").
|
|
1316
|
+
* @param opts.permissions Permission granted to the created directory (e.g., 0777).
|
|
1317
|
+
*
|
|
1318
|
+
* Default: 0755.
|
|
1112
1319
|
*/
|
|
1113
1320
|
withNewDirectory(path, opts) {
|
|
1114
1321
|
return new Directory({
|
|
@@ -1125,6 +1332,11 @@ export class Directory extends BaseClient {
|
|
|
1125
1332
|
}
|
|
1126
1333
|
/**
|
|
1127
1334
|
* Retrieves this directory plus a new file written at the given path.
|
|
1335
|
+
* @param path Location of the written file (e.g., "/file.txt").
|
|
1336
|
+
* @param contents Content of the written file (e.g., "Hello world!").
|
|
1337
|
+
* @param opts.permissions Permission given to the copied file (e.g., 0600).
|
|
1338
|
+
*
|
|
1339
|
+
* Default: 0644.
|
|
1128
1340
|
*/
|
|
1129
1341
|
withNewFile(path, contents, opts) {
|
|
1130
1342
|
return new Directory({
|
|
@@ -1140,7 +1352,10 @@ export class Directory extends BaseClient {
|
|
|
1140
1352
|
});
|
|
1141
1353
|
}
|
|
1142
1354
|
/**
|
|
1143
|
-
* Retrieves this directory with all file/dir timestamps set to the given time
|
|
1355
|
+
* Retrieves this directory with all file/dir timestamps set to the given time.
|
|
1356
|
+
* @param timestamp Timestamp to set dir/files in.
|
|
1357
|
+
*
|
|
1358
|
+
* Formatted in seconds following Unix epoch (e.g., 1672531199).
|
|
1144
1359
|
*/
|
|
1145
1360
|
withTimestamps(timestamp) {
|
|
1146
1361
|
return new Directory({
|
|
@@ -1157,6 +1372,7 @@ export class Directory extends BaseClient {
|
|
|
1157
1372
|
}
|
|
1158
1373
|
/**
|
|
1159
1374
|
* Retrieves this directory with the directory at the given path removed.
|
|
1375
|
+
* @param path Location of the directory to remove (e.g., ".github/").
|
|
1160
1376
|
*/
|
|
1161
1377
|
withoutDirectory(path) {
|
|
1162
1378
|
return new Directory({
|
|
@@ -1173,6 +1389,7 @@ export class Directory extends BaseClient {
|
|
|
1173
1389
|
}
|
|
1174
1390
|
/**
|
|
1175
1391
|
* Retrieves this directory with the file at the given path removed.
|
|
1392
|
+
* @param path Location of the file to remove (e.g., "/file.txt").
|
|
1176
1393
|
*/
|
|
1177
1394
|
withoutFile(path) {
|
|
1178
1395
|
return new Directory({
|
|
@@ -1289,6 +1506,7 @@ export class File extends BaseClient {
|
|
|
1289
1506
|
}
|
|
1290
1507
|
/**
|
|
1291
1508
|
* Writes the file to a file path on the host.
|
|
1509
|
+
* @param path Location of the written directory (e.g., "output.txt").
|
|
1292
1510
|
*/
|
|
1293
1511
|
export(path) {
|
|
1294
1512
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -1346,7 +1564,10 @@ export class File extends BaseClient {
|
|
|
1346
1564
|
});
|
|
1347
1565
|
}
|
|
1348
1566
|
/**
|
|
1349
|
-
* Retrieves this file with its created/modified timestamps set to the given time
|
|
1567
|
+
* Retrieves this file with its created/modified timestamps set to the given time.
|
|
1568
|
+
* @param timestamp Timestamp to set dir/files in.
|
|
1569
|
+
*
|
|
1570
|
+
* Formatted in seconds following Unix epoch (e.g., 1672531199).
|
|
1350
1571
|
*/
|
|
1351
1572
|
withTimestamps(timestamp) {
|
|
1352
1573
|
return new File({
|
|
@@ -1451,6 +1672,7 @@ export class GitRef extends BaseClient {
|
|
|
1451
1672
|
export class GitRepository extends BaseClient {
|
|
1452
1673
|
/**
|
|
1453
1674
|
* Returns details on one branch.
|
|
1675
|
+
* @param name Branch's name (e.g., "main").
|
|
1454
1676
|
*/
|
|
1455
1677
|
branch(name) {
|
|
1456
1678
|
return new GitRef({
|
|
@@ -1481,6 +1703,7 @@ export class GitRepository extends BaseClient {
|
|
|
1481
1703
|
}
|
|
1482
1704
|
/**
|
|
1483
1705
|
* Returns details on one commit.
|
|
1706
|
+
* @param id Identifier of the commit (e.g., "b6315d8f2810962c601af73f86831f6866ea798b").
|
|
1484
1707
|
*/
|
|
1485
1708
|
commit(id) {
|
|
1486
1709
|
return new GitRef({
|
|
@@ -1497,6 +1720,7 @@ export class GitRepository extends BaseClient {
|
|
|
1497
1720
|
}
|
|
1498
1721
|
/**
|
|
1499
1722
|
* Returns details on one tag.
|
|
1723
|
+
* @param name Tag's name (e.g., "v0.3.9").
|
|
1500
1724
|
*/
|
|
1501
1725
|
tag(name) {
|
|
1502
1726
|
return new GitRef({
|
|
@@ -1556,6 +1780,9 @@ export class GitRepository extends BaseClient {
|
|
|
1556
1780
|
export class Host extends BaseClient {
|
|
1557
1781
|
/**
|
|
1558
1782
|
* Accesses a directory on the host.
|
|
1783
|
+
* @param path Location of the directory to access (e.g., ".").
|
|
1784
|
+
* @param opts.exclude Exclude artifacts that match the given pattern (e.g., ["node_modules/", ".git*"]).
|
|
1785
|
+
* @param opts.include Include only artifacts that match the given pattern (e.g., ["app/", "package.*"]).
|
|
1559
1786
|
*/
|
|
1560
1787
|
directory(path, opts) {
|
|
1561
1788
|
return new Directory({
|
|
@@ -1572,6 +1799,7 @@ export class Host extends BaseClient {
|
|
|
1572
1799
|
}
|
|
1573
1800
|
/**
|
|
1574
1801
|
* Accesses an environment variable on the host.
|
|
1802
|
+
* @param name Name of the environment variable (e.g., "PATH").
|
|
1575
1803
|
*/
|
|
1576
1804
|
envVariable(name) {
|
|
1577
1805
|
return new HostVariable({
|
|
@@ -1588,6 +1816,7 @@ export class Host extends BaseClient {
|
|
|
1588
1816
|
}
|
|
1589
1817
|
/**
|
|
1590
1818
|
* Accesses a Unix socket on the host.
|
|
1819
|
+
* @param path Location of the Unix socket (e.g., "/var/run/docker.sock").
|
|
1591
1820
|
*/
|
|
1592
1821
|
unixSocket(path) {
|
|
1593
1822
|
return new Socket({
|
|
@@ -1604,6 +1833,8 @@ export class Host extends BaseClient {
|
|
|
1604
1833
|
}
|
|
1605
1834
|
/**
|
|
1606
1835
|
* Retrieves the current working directory on the host.
|
|
1836
|
+
* @param opts.exclude Exclude artifacts that match the given pattern (e.g., ["node_modules/", ".git*"]).
|
|
1837
|
+
* @param opts.include Include only artifacts that match the given pattern (e.g., ["app/", "package.*"]).
|
|
1607
1838
|
* @deprecated Use directory with path set to '.' instead.
|
|
1608
1839
|
*/
|
|
1609
1840
|
workdir(opts) {
|
|
@@ -1759,6 +1990,77 @@ export class Label extends BaseClient {
|
|
|
1759
1990
|
return arg(this);
|
|
1760
1991
|
}
|
|
1761
1992
|
}
|
|
1993
|
+
/**
|
|
1994
|
+
* A port exposed by a container.
|
|
1995
|
+
*/
|
|
1996
|
+
export class Port extends BaseClient {
|
|
1997
|
+
/**
|
|
1998
|
+
* The port description.
|
|
1999
|
+
*/
|
|
2000
|
+
description() {
|
|
2001
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2002
|
+
const response = yield computeQuery([
|
|
2003
|
+
...this._queryTree,
|
|
2004
|
+
{
|
|
2005
|
+
operation: "description",
|
|
2006
|
+
},
|
|
2007
|
+
], this.client);
|
|
2008
|
+
return response;
|
|
2009
|
+
});
|
|
2010
|
+
}
|
|
2011
|
+
/**
|
|
2012
|
+
* The port number.
|
|
2013
|
+
*/
|
|
2014
|
+
port() {
|
|
2015
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2016
|
+
const response = yield computeQuery([
|
|
2017
|
+
...this._queryTree,
|
|
2018
|
+
{
|
|
2019
|
+
operation: "port",
|
|
2020
|
+
},
|
|
2021
|
+
], this.client);
|
|
2022
|
+
return response;
|
|
2023
|
+
});
|
|
2024
|
+
}
|
|
2025
|
+
/**
|
|
2026
|
+
* The transport layer network protocol.
|
|
2027
|
+
*/
|
|
2028
|
+
protocol() {
|
|
2029
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2030
|
+
const response = yield computeQuery([
|
|
2031
|
+
...this._queryTree,
|
|
2032
|
+
{
|
|
2033
|
+
operation: "protocol",
|
|
2034
|
+
},
|
|
2035
|
+
], this.client);
|
|
2036
|
+
return response;
|
|
2037
|
+
});
|
|
2038
|
+
}
|
|
2039
|
+
/**
|
|
2040
|
+
* Chain objects together
|
|
2041
|
+
* @example
|
|
2042
|
+
* ```ts
|
|
2043
|
+
* function AddAFewMounts(c) {
|
|
2044
|
+
* return c
|
|
2045
|
+
* .withMountedDirectory("/foo", new Client().host().directory("/Users/slumbering/forks/dagger"))
|
|
2046
|
+
* .withMountedDirectory("/bar", new Client().host().directory("/Users/slumbering/forks/dagger/sdk/nodejs"))
|
|
2047
|
+
* }
|
|
2048
|
+
*
|
|
2049
|
+
* connect(async (client) => {
|
|
2050
|
+
* const tree = await client
|
|
2051
|
+
* .container()
|
|
2052
|
+
* .from("alpine")
|
|
2053
|
+
* .withWorkdir("/foo")
|
|
2054
|
+
* .with(AddAFewMounts)
|
|
2055
|
+
* .withExec(["ls", "-lh"])
|
|
2056
|
+
* .stdout()
|
|
2057
|
+
* })
|
|
2058
|
+
*```
|
|
2059
|
+
*/
|
|
2060
|
+
with(arg) {
|
|
2061
|
+
return arg(this);
|
|
2062
|
+
}
|
|
2063
|
+
}
|
|
1762
2064
|
/**
|
|
1763
2065
|
* A set of scripts and/or extensions
|
|
1764
2066
|
*/
|
|
@@ -1876,7 +2178,7 @@ export class Project extends BaseClient {
|
|
|
1876
2178
|
export default class Client extends BaseClient {
|
|
1877
2179
|
/**
|
|
1878
2180
|
* Constructs a cache volume for a given cache key.
|
|
1879
|
-
* @param key A string identifier to target this cache volume (e.g
|
|
2181
|
+
* @param key A string identifier to target this cache volume (e.g., "modules-cache").
|
|
1880
2182
|
*/
|
|
1881
2183
|
cacheVolume(key) {
|
|
1882
2184
|
return new CacheVolume({
|
|
@@ -1893,8 +2195,10 @@ export default class Client extends BaseClient {
|
|
|
1893
2195
|
}
|
|
1894
2196
|
/**
|
|
1895
2197
|
* Loads a container from ID.
|
|
2198
|
+
*
|
|
1896
2199
|
* Null ID returns an empty container (scratch).
|
|
1897
|
-
* Optional platform argument initializes new containers to execute and publish as that platform.
|
|
2200
|
+
* Optional platform argument initializes new containers to execute and publish as that platform.
|
|
2201
|
+
* Platform defaults to that of the builder's host.
|
|
1898
2202
|
*/
|
|
1899
2203
|
container(opts) {
|
|
1900
2204
|
return new Container({
|
|
@@ -1957,6 +2261,11 @@ export default class Client extends BaseClient {
|
|
|
1957
2261
|
}
|
|
1958
2262
|
/**
|
|
1959
2263
|
* Queries a git repository.
|
|
2264
|
+
* @param url Url of the git repository.
|
|
2265
|
+
* Can be formatted as https://{host}/{owner}/{repo}, git@{host}/{owner}/{repo}
|
|
2266
|
+
* Suffix ".git" is optional.
|
|
2267
|
+
* @param opts.keepGitDir Set to true to keep .git directory.
|
|
2268
|
+
* @param opts.experimentalServiceHost A service which must be started before the repo is fetched.
|
|
1960
2269
|
*/
|
|
1961
2270
|
git(url, opts) {
|
|
1962
2271
|
return new GitRepository({
|
|
@@ -1988,14 +2297,16 @@ export default class Client extends BaseClient {
|
|
|
1988
2297
|
}
|
|
1989
2298
|
/**
|
|
1990
2299
|
* Returns a file containing an http remote url content.
|
|
2300
|
+
* @param url HTTP url to get the content from (e.g., "https://docs.dagger.io").
|
|
2301
|
+
* @param opts.experimentalServiceHost A service which must be started before the URL is fetched.
|
|
1991
2302
|
*/
|
|
1992
|
-
http(url) {
|
|
2303
|
+
http(url, opts) {
|
|
1993
2304
|
return new File({
|
|
1994
2305
|
queryTree: [
|
|
1995
2306
|
...this._queryTree,
|
|
1996
2307
|
{
|
|
1997
2308
|
operation: "http",
|
|
1998
|
-
args: { url },
|
|
2309
|
+
args: Object.assign({ url }, opts),
|
|
1999
2310
|
},
|
|
2000
2311
|
],
|
|
2001
2312
|
host: this.clientHost,
|