@go-to-k/cdkd 0.69.0 → 0.71.0

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.
Binary file
package/dist/index.js CHANGED
@@ -2486,14 +2486,57 @@ var FileAssetPublisher = class {
2486
2486
  };
2487
2487
 
2488
2488
  // src/assets/docker-asset-publisher.ts
2489
- import { execFile, spawn as spawn2 } from "node:child_process";
2490
- import { promisify } from "node:util";
2489
+ import { execFile as execFile2, spawn as spawn2 } from "node:child_process";
2490
+ import { promisify as promisify2 } from "node:util";
2491
2491
  import {
2492
2492
  ECRClient,
2493
2493
  GetAuthorizationTokenCommand,
2494
2494
  DescribeImagesCommand as DescribeImagesCommand2
2495
2495
  } from "@aws-sdk/client-ecr";
2496
+
2497
+ // src/assets/docker-build.ts
2498
+ import { execFile } from "node:child_process";
2499
+ import { promisify } from "node:util";
2496
2500
  var execFileAsync = promisify(execFile);
2501
+ async function buildDockerImage(asset, cdkOutDir, tag, options) {
2502
+ const logger = getLogger().child("docker-build");
2503
+ const args = ["build", "-t", tag];
2504
+ if (options.platform) {
2505
+ args.push("--platform", options.platform);
2506
+ }
2507
+ if (asset.source.dockerFile) {
2508
+ args.push("-f", asset.source.dockerFile);
2509
+ }
2510
+ if (asset.source.dockerBuildArgs) {
2511
+ for (const [key, value] of Object.entries(asset.source.dockerBuildArgs)) {
2512
+ args.push("--build-arg", `${key}=${value}`);
2513
+ }
2514
+ }
2515
+ if (asset.source.dockerBuildTarget) {
2516
+ args.push("--target", asset.source.dockerBuildTarget);
2517
+ }
2518
+ if (asset.source.dockerOutputs) {
2519
+ for (const output of asset.source.dockerOutputs) {
2520
+ args.push("--output", output);
2521
+ }
2522
+ }
2523
+ const contextDir = `${cdkOutDir}/${asset.source.directory}`;
2524
+ args.push(contextDir);
2525
+ logger.debug(`docker ${args.join(" ")}`);
2526
+ try {
2527
+ await execFileAsync("docker", args, {
2528
+ maxBuffer: 50 * 1024 * 1024
2529
+ // 50MB for build output
2530
+ });
2531
+ } catch (error) {
2532
+ const err = error;
2533
+ const stderr = err.stderr || err.message || String(error);
2534
+ throw options.wrapError(stderr);
2535
+ }
2536
+ }
2537
+
2538
+ // src/assets/docker-asset-publisher.ts
2539
+ var execFileAsync2 = promisify2(execFile2);
2497
2540
  var DockerAssetPublisher = class {
2498
2541
  logger = getLogger().child("DockerAssetPublisher");
2499
2542
  /**
@@ -2576,38 +2619,17 @@ var DockerAssetPublisher = class {
2576
2619
  }
2577
2620
  }
2578
2621
  /**
2579
- * Build Docker image
2622
+ * Build Docker image — delegates to the shared `buildDockerImage`
2623
+ * helper so this code path stays in sync with `cdkd local invoke`'s
2624
+ * container-Lambda build path. `--platform` is currently not threaded
2625
+ * through here (publish-assets has no Architectures hint to consult);
2626
+ * a follow-up can lift this once the asset manifest carries a
2627
+ * platform field.
2580
2628
  */
2581
2629
  async buildImage(asset, cdkOutputDir, tag) {
2582
- const args = ["build", "-t", tag];
2583
- if (asset.source.dockerFile) {
2584
- args.push("-f", asset.source.dockerFile);
2585
- }
2586
- if (asset.source.dockerBuildArgs) {
2587
- for (const [key, value] of Object.entries(asset.source.dockerBuildArgs)) {
2588
- args.push("--build-arg", `${key}=${value}`);
2589
- }
2590
- }
2591
- if (asset.source.dockerBuildTarget) {
2592
- args.push("--target", asset.source.dockerBuildTarget);
2593
- }
2594
- if (asset.source.dockerOutputs) {
2595
- for (const output of asset.source.dockerOutputs) {
2596
- args.push("--output", output);
2597
- }
2598
- }
2599
- const contextDir = `${cdkOutputDir}/${asset.source.directory}`;
2600
- args.push(contextDir);
2601
- this.logger.debug(`docker ${args.join(" ")}`);
2602
- try {
2603
- await execFileAsync("docker", args, {
2604
- maxBuffer: 50 * 1024 * 1024
2605
- // 50MB for build output
2606
- });
2607
- } catch (error) {
2608
- const err = error;
2609
- throw new AssetError(`Docker build failed: ${err.stderr || err.message || String(error)}`);
2610
- }
2630
+ await buildDockerImage(asset, cdkOutputDir, tag, {
2631
+ wrapError: (stderr) => new AssetError(`Docker build failed: ${stderr}`)
2632
+ });
2611
2633
  }
2612
2634
  /**
2613
2635
  * Authenticate with ECR
@@ -2651,7 +2673,7 @@ var DockerAssetPublisher = class {
2651
2673
  * Tag Docker image
2652
2674
  */
2653
2675
  async tagImage(source, target) {
2654
- await execFileAsync("docker", ["tag", source, target]);
2676
+ await execFileAsync2("docker", ["tag", source, target]);
2655
2677
  }
2656
2678
  /**
2657
2679
  * Push Docker image
@@ -2659,7 +2681,7 @@ var DockerAssetPublisher = class {
2659
2681
  async pushImage(uri) {
2660
2682
  this.logger.debug(`Pushing: ${uri}`);
2661
2683
  try {
2662
- await execFileAsync("docker", ["push", uri], {
2684
+ await execFileAsync2("docker", ["push", uri], {
2663
2685
  maxBuffer: 50 * 1024 * 1024
2664
2686
  });
2665
2687
  } catch (error) {