UNPKG

4.67 kBJavaScriptView Raw
1"use strict";
2var _a;
3Object.defineProperty(exports, "__esModule", { value: true });
4exports.AssetImage = void 0;
5const jsiiDeprecationWarnings = require("../../.warnings.jsii.js");
6const JSII_RTTI_SYMBOL_1 = Symbol.for("jsii.rtti");
7const aws_ecr_assets_1 = require("@aws-cdk/aws-ecr-assets");
8const container_image_1 = require("../container-image");
9/**
10 * An image that will be built from a local directory with a Dockerfile
11 */
12class AssetImage extends container_image_1.ContainerImage {
13 /**
14 * Constructs a new instance of the AssetImage class.
15 *
16 * @param directory The directory containing the Dockerfile
17 */
18 constructor(directory, props = {}) {
19 super();
20 this.directory = directory;
21 this.props = props;
22 try {
23 jsiiDeprecationWarnings._aws_cdk_aws_ecs_AssetImageProps(props);
24 }
25 catch (error) {
26 if (process.env.JSII_DEBUG !== "1" && error.name === "DeprecationError") {
27 Error.captureStackTrace(error, AssetImage);
28 }
29 throw error;
30 }
31 }
32 bind(scope, containerDefinition) {
33 try {
34 jsiiDeprecationWarnings._aws_cdk_aws_ecs_ContainerDefinition(containerDefinition);
35 }
36 catch (error) {
37 if (process.env.JSII_DEBUG !== "1" && error.name === "DeprecationError") {
38 Error.captureStackTrace(error, this.bind);
39 }
40 throw error;
41 }
42 const asset = new aws_ecr_assets_1.DockerImageAsset(scope, 'AssetImage', {
43 directory: this.directory,
44 ...this.props,
45 });
46 asset.repository.grantPull(containerDefinition.taskDefinition.obtainExecutionRole());
47 return {
48 imageName: asset.imageUri,
49 };
50 }
51}
52exports.AssetImage = AssetImage;
53_a = JSII_RTTI_SYMBOL_1;
54AssetImage[_a] = { fqn: "@aws-cdk/aws-ecs.AssetImage", version: "1.204.0" };
55//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXNzZXQtaW1hZ2UuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyJhc3NldC1pbWFnZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs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