Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Provisioning a custom Docker image on AWS CodeBuild takes a very long time

My Dockerfile:

FROM mcr.microsoft.com/dotnet/framework/sdk:4.8-windowsservercore-ltsc2016
COPY AWSCLIV2.msi .
RUN Start-Process msiexec.exe -Wait -ArgumentList '/I AWSCLIV2.msi /quiet /qn /norestart /log awscli.log'
RUN rm AWSCLIV2.msi

My CodeBuild environment needs to be able to build a .NET Framework project as well as use AWS CLI. Due to limitations, I can only have one CodeBuild stage. I push to ECR the docker image created using the above Dockerfile and set my CodeBuild environment to use that image. However it takes ~10 minutes to provision.

CodeBuild provides caching that only lasts ~15 minutes which is not helpful for more infrequent builds. I also found this solution that others linked to https://github.com/aws/aws-codebuild-docker-images/issues/26#issuecomment-370177343 but I'm not sure how it can be applied to Windows containers.

If anyone has any pointers on decreasing the provisioning time, I would really appreciate it.

like image 273
Do Yeon Kim Avatar asked Nov 04 '25 12:11

Do Yeon Kim


1 Answers

Windows images are large, so the provisioning time which includes the time to pull down the custom image to CodeBuild instance will be relatively long.

There are two approaches that can help:

  1. Use CodeBuild provided images for the build environment, as the latest version for these images are pre-cached on the build servers.
  2. Use the base layer for the custom image same as that of CodeBuild image, so that the base layer could be reused and won't incur download time. e.g.:

    • For Microsoft Windows, use a Windows container with a container OS that is version microsoft/windowsservercore:10.0.x (for example, microsoft/windowsservercore:10.0.14393.2125). Link
like image 132
shariqmaws Avatar answered Nov 06 '25 02:11

shariqmaws



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!