Support Docker Image Server of CodeBuild
This can significantly speed up ContainerImageBuild jobs (and possibly NodejsBuild) when users frequently change assets and deploy a stack. https://aws.amazon.com/blogs/aws/accelerate-ci-cd-pipelines-with-the-new-aws-codebuild-docker-server-capability/
Basically, we want to resolve the issue described here more elegantly:
https://github.com/tmokmss/deploy-time-build/blob/cb11c0eb1446c46b7ae2f160c104f760c8c82d09/README.md?plain=1#L106-L122
Note that for many users who just deploy a stack only once (e.g. users of GenU/BrChat), it will introduce additional cost without much benefit, so we have to carefully evaluate when implementing this feature. Maybe we need an explicit flag to enable the feature, or we just do not need this feature.
related: https://github.com/aws/aws-cdk/issues/34494
It does not seem to support Arm environment yet.
10:26:32 AM | UPDATE_FAILED | AWS::CodeBuild::Project | ContainerImageBuil...47a30amd64C13E3549 Failed to call UpdateProject, reason: Unsupported DockerServer environment type: ARM_CONTAINER (Service: AWSCodeBuild; Status Code: 400; Error Code: Invalid InputException; Request ID: ; Proxy: null)
We must not execute docker buildx create --use because it overrides the required configuration for CodeBuild docker server. (resolved with https://github.com/tmokmss/deploy-time-build/issues/49)
https://github.com/tmokmss/deploy-time-build/blob/c97f9dd0485019eb1fbc38eaed4a28ce63172aa3/src/container-image-build.ts#L108
Current workaround using escape hatch:
// Use ContainerImageBuild to inject deploy-time values in the build environment
const image = new ContainerImageBuild(this, 'Build', {
directory: join('..', 'app'),
platform: Platform.LINUX_AMD64,
});
{
// find the logical id from the synthesized template
const project = Stack.of(this).node.findChild('ContainerImageBuildAmd64e83729feb1564e709bec452b15847a30amd64')
.node.defaultChild as CfnResource;
project.addPropertyOverride('Environment.DockerServer', { ComputeType: 'BUILD_GENERAL1_SMALL' });
}
Looking forward to this! 👏