1 | /**
|
2 | * Bundling options
|
3 | *
|
4 | */
|
5 | export interface BundlingOptions {
|
6 | /**
|
7 | * The Docker image where the command will run.
|
8 | */
|
9 | readonly image: DockerImage;
|
10 | /**
|
11 | * The entrypoint to run in the Docker container.
|
12 | *
|
13 | * Example value: `['/bin/sh', '-c']`
|
14 | *
|
15 | * @see https://docs.docker.com/engine/reference/builder/#entrypoint
|
16 | *
|
17 | * @default - run the entrypoint defined in the image
|
18 | */
|
19 | readonly entrypoint?: string[];
|
20 | /**
|
21 | * The command to run in the Docker container.
|
22 | *
|
23 | * Example value: `['npm', 'install']`
|
24 | *
|
25 | * @see https://docs.docker.com/engine/reference/run/
|
26 | *
|
27 | * @default - run the command defined in the image
|
28 | */
|
29 | readonly command?: string[];
|
30 | /**
|
31 | * Additional Docker volumes to mount.
|
32 | *
|
33 | * @default - no additional volumes are mounted
|
34 | */
|
35 | readonly volumes?: DockerVolume[];
|
36 | /**
|
37 | * The environment variables to pass to the Docker container.
|
38 | *
|
39 | * @default - no environment variables.
|
40 | */
|
41 | readonly environment?: {
|
42 | [key: string]: string;
|
43 | };
|
44 | /**
|
45 | * Working directory inside the Docker container.
|
46 | *
|
47 | * @default /asset-input
|
48 | */
|
49 | readonly workingDirectory?: string;
|
50 | /**
|
51 | * The user to use when running the Docker container.
|
52 | *
|
53 | * user | user:group | uid | uid:gid | user:gid | uid:group
|
54 | *
|
55 | * @see https://docs.docker.com/engine/reference/run/#user
|
56 | *
|
57 | * @default - uid:gid of the current user or 1000:1000 on Windows
|
58 | */
|
59 | readonly user?: string;
|
60 | /**
|
61 | * Local bundling provider.
|
62 | *
|
63 | * The provider implements a method `tryBundle()` which should return `true`
|
64 | * if local bundling was performed. If `false` is returned, docker bundling
|
65 | * will be done.
|
66 | *
|
67 | * @default - bundling will only be performed in a Docker container
|
68 | *
|
69 | */
|
70 | readonly local?: ILocalBundling;
|
71 | /**
|
72 | * The type of output that this bundling operation is producing.
|
73 | *
|
74 | * @default BundlingOutput.AUTO_DISCOVER
|
75 | *
|
76 | */
|
77 | readonly outputType?: BundlingOutput;
|
78 | /**
|
79 | * [Security configuration](https://docs.docker.com/engine/reference/run/#security-configuration)
|
80 | * when running the docker container.
|
81 | *
|
82 | * @default - no security options
|
83 | */
|
84 | readonly securityOpt?: string;
|
85 | }
|
86 | /**
|
87 | * The type of output that a bundling operation is producing.
|
88 | *
|
89 | */
|
90 | export declare enum BundlingOutput {
|
91 | /**
|
92 | * The bundling output directory includes a single .zip or .jar file which
|
93 | * will be used as the final bundle. If the output directory does not
|
94 | * include exactly a single archive, bundling will fail.
|
95 | */
|
96 | ARCHIVED = "archived",
|
97 | /**
|
98 | * The bundling output directory contains one or more files which will be
|
99 | * archived and uploaded as a .zip file to S3.
|
100 | */
|
101 | NOT_ARCHIVED = "not-archived",
|
102 | /**
|
103 | * If the bundling output directory contains a single archive file (zip or jar)
|
104 | * it will be used as the bundle output as-is. Otherwise all the files in the bundling output directory will be zipped.
|
105 | */
|
106 | AUTO_DISCOVER = "auto-discover"
|
107 | }
|
108 | /**
|
109 | * Local bundling
|
110 | *
|
111 | */
|
112 | export interface ILocalBundling {
|
113 | /**
|
114 | * This method is called before attempting docker bundling to allow the
|
115 | * bundler to be executed locally. If the local bundler exists, and bundling
|
116 | * was performed locally, return `true`. Otherwise, return `false`.
|
117 | *
|
118 | * @param outputDir the directory where the bundled asset should be output
|
119 | * @param options bundling options for this asset
|
120 | */
|
121 | tryBundle(outputDir: string, options: BundlingOptions): boolean;
|
122 | }
|
123 | /**
|
124 | * A Docker image used for asset bundling
|
125 | *
|
126 | * @deprecated use DockerImage
|
127 | */
|
128 | export declare class BundlingDockerImage {
|
129 | readonly image: string;
|
130 | private readonly _imageHash?;
|
131 | /**
|
132 | * Reference an image on DockerHub or another online registry.
|
133 | *
|
134 | * @param image the image name
|
135 | */
|
136 | static fromRegistry(image: string): DockerImage;
|
137 | /**
|
138 | * Reference an image that's built directly from sources on disk.
|
139 | *
|
140 | * @param path The path to the directory containing the Docker file
|
141 | * @param options Docker build options
|
142 | *
|
143 | * @deprecated use DockerImage.fromBuild()
|
144 | */
|
145 | static fromAsset(path: string, options?: DockerBuildOptions): BundlingDockerImage;
|
146 | /** @param image The Docker image */
|
147 | protected constructor(image: string, _imageHash?: string | undefined);
|
148 | /**
|
149 | * Provides a stable representation of this image for JSON serialization.
|
150 | *
|
151 | * @return The overridden image name if set or image hash name in that order
|
152 | */
|
153 | toJSON(): string;
|
154 | /**
|
155 | * Runs a Docker image
|
156 | */
|
157 | run(options?: DockerRunOptions): void;
|
158 | /**
|
159 | * Copies a file or directory out of the Docker image to the local filesystem.
|
160 | *
|
161 | * If `outputPath` is omitted the destination path is a temporary directory.
|
162 | *
|
163 | * @param imagePath the path in the Docker image
|
164 | * @param outputPath the destination path for the copy operation
|
165 | * @returns the destination path
|
166 | */
|
167 | cp(imagePath: string, outputPath?: string): string;
|
168 | }
|
169 | /**
|
170 | * A Docker image
|
171 | */
|
172 | export declare class DockerImage extends BundlingDockerImage {
|
173 | /**
|
174 | * Builds a Docker image
|
175 | *
|
176 | * @param path The path to the directory containing the Docker file
|
177 | * @param options Docker build options
|
178 | */
|
179 | static fromBuild(path: string, options?: DockerBuildOptions): DockerImage;
|
180 | /**
|
181 | * Reference an image on DockerHub or another online registry.
|
182 | *
|
183 | * @param image the image name
|
184 | */
|
185 | static fromRegistry(image: string): DockerImage;
|
186 | /** The Docker image */
|
187 | readonly image: string;
|
188 | constructor(image: string, _imageHash?: string);
|
189 | /**
|
190 | * Provides a stable representation of this image for JSON serialization.
|
191 | *
|
192 | * @return The overridden image name if set or image hash name in that order
|
193 | */
|
194 | toJSON(): string;
|
195 | /**
|
196 | * Runs a Docker image
|
197 | */
|
198 | run(options?: DockerRunOptions): void;
|
199 | /**
|
200 | * Copies a file or directory out of the Docker image to the local filesystem.
|
201 | *
|
202 | * If `outputPath` is omitted the destination path is a temporary directory.
|
203 | *
|
204 | * @param imagePath the path in the Docker image
|
205 | * @param outputPath the destination path for the copy operation
|
206 | * @returns the destination path
|
207 | */
|
208 | cp(imagePath: string, outputPath?: string): string;
|
209 | }
|
210 | /**
|
211 | * A Docker volume
|
212 | */
|
213 | export interface DockerVolume {
|
214 | /**
|
215 | * The path to the file or directory on the host machine
|
216 | */
|
217 | readonly hostPath: string;
|
218 | /**
|
219 | * The path where the file or directory is mounted in the container
|
220 | */
|
221 | readonly containerPath: string;
|
222 | /**
|
223 | * Mount consistency. Only applicable for macOS
|
224 | *
|
225 | * @default DockerConsistency.DELEGATED
|
226 | * @see https://docs.docker.com/storage/bind-mounts/#configure-mount-consistency-for-macos
|
227 | */
|
228 | readonly consistency?: DockerVolumeConsistency;
|
229 | }
|
230 | /**
|
231 | * Supported Docker volume consistency types. Only valid on macOS due to the way file storage works on Mac
|
232 | */
|
233 | export declare enum DockerVolumeConsistency {
|
234 | /**
|
235 | * Read/write operations inside the Docker container are applied immediately on the mounted host machine volumes
|
236 | */
|
237 | CONSISTENT = "consistent",
|
238 | /**
|
239 | * Read/write operations on mounted Docker volumes are first written inside the container and then synchronized to the host machine
|
240 | */
|
241 | DELEGATED = "delegated",
|
242 | /**
|
243 | * Read/write operations on mounted Docker volumes are first applied on the host machine and then synchronized to the container
|
244 | */
|
245 | CACHED = "cached"
|
246 | }
|
247 | /**
|
248 | * Docker run options
|
249 | */
|
250 | export interface DockerRunOptions {
|
251 | /**
|
252 | * The entrypoint to run in the container.
|
253 | *
|
254 | * @default - run the entrypoint defined in the image
|
255 | */
|
256 | readonly entrypoint?: string[];
|
257 | /**
|
258 | * The command to run in the container.
|
259 | *
|
260 | * @default - run the command defined in the image
|
261 | */
|
262 | readonly command?: string[];
|
263 | /**
|
264 | * Docker volumes to mount.
|
265 | *
|
266 | * @default - no volumes are mounted
|
267 | */
|
268 | readonly volumes?: DockerVolume[];
|
269 | /**
|
270 | * The environment variables to pass to the container.
|
271 | *
|
272 | * @default - no environment variables.
|
273 | */
|
274 | readonly environment?: {
|
275 | [key: string]: string;
|
276 | };
|
277 | /**
|
278 | * Working directory inside the container.
|
279 | *
|
280 | * @default - image default
|
281 | */
|
282 | readonly workingDirectory?: string;
|
283 | /**
|
284 | * The user to use when running the container.
|
285 | *
|
286 | * @default - root or image default
|
287 | */
|
288 | readonly user?: string;
|
289 | /**
|
290 | * [Security configuration](https://docs.docker.com/engine/reference/run/#security-configuration)
|
291 | * when running the docker container.
|
292 | *
|
293 | * @default - no security options
|
294 | */
|
295 | readonly securityOpt?: string;
|
296 | }
|
297 | /**
|
298 | * Docker build options
|
299 | */
|
300 | export interface DockerBuildOptions {
|
301 | /**
|
302 | * Build args
|
303 | *
|
304 | * @default - no build args
|
305 | */
|
306 | readonly buildArgs?: {
|
307 | [key: string]: string;
|
308 | };
|
309 | /**
|
310 | * Name of the Dockerfile, must relative to the docker build path.
|
311 | *
|
312 | * @default `Dockerfile`
|
313 | */
|
314 | readonly file?: string;
|
315 | /**
|
316 | * Set platform if server is multi-platform capable. _Requires Docker Engine API v1.38+_.
|
317 | *
|
318 | * Example value: `linux/amd64`
|
319 | *
|
320 | * @default - no platform specified
|
321 | */
|
322 | readonly platform?: string;
|
323 | }
|