deploy-time-build icon indicating copy to clipboard operation
deploy-time-build copied to clipboard

Support Docker Image Server of CodeBuild

Open tmokmss opened this issue 7 months ago • 5 comments

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.

tmokmss avatar May 17 '25 15:05 tmokmss

related: https://github.com/aws/aws-cdk/issues/34494

tmokmss avatar May 23 '25 07:05 tmokmss

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)

tmokmss avatar Jul 13 '25 01:07 tmokmss

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

tmokmss avatar Jul 30 '25 13:07 tmokmss

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' });
    }

tmokmss avatar Sep 18 '25 01:09 tmokmss

Looking forward to this! 👏

BwL1289 avatar Oct 09 '25 20:10 BwL1289