cdklabs / cdklabs/deploy-time-build

Expose computeType property for ContainerImageBuild

Open
#76 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
12
Forks
1
Avg merge
12h 28m
Merged PRs (30d)
2

Description

## Problem

`NodejsBuild` and `SociIndexV2Build` already expose a `computeType` property, but `ContainerImageBuild` does not — it is hardcoded to `ComputeType.SMALL` in `src/container-image-build.ts`.

When building large Docker images (e.g. Next.js applications), `SMALL` (3 GB RAM) is often insufficient, causing out-of-memory errors or slow build times. Users need to increase the compute type to `MEDIUM` or higher.

The current workaround requires an escape hatch that is fragile and non-obvious, because `ContainerImageBuild` uses a `SingletonProject` internally:

```typescript
import { Project, CfnResource } from "aws-cdk-lib/aws-codebuild";

const arm64Project = this.node.children.find(
(c): c is Project =>
c instanceof Project && c.node.id.startsWith("ContainerImageBuildArm64")
);
if (arm64Project) {
(arm64Project.node.defaultChild as CfnResource).addPropertyOverride(
"Environment.ComputeType",
"BUILD_GENERAL1_MEDIUM"
);
}
```

## Proposal

Add a `computeType` property to `ContainerImageBuildProps`, consistent with the existing `NodejsBuild` interface.

## References

- [tmokmss/deploy-time-build#26](https://github.com/tmokmss/deploy-time-build/issues/26) — Same issue filed in the original repo, resolved by PR #71 for `NodejsBuild`
- [tmokmss/deploy-time-build#19](https://github.com/tmokmss/deploy-time-build/issues/19) — Escape hatch workaround

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.