AWS Blogs 05月16日 03:28
Accelerate CI/CD pipelines with the new AWS CodeBuild Docker Server capability
index_new5.html
../../../zaker_core/zaker_tpl_static/wap/tpl_guoji1.html

 

AWS CodeBuild推出Docker Server功能,旨在通过在CodeBuild项目中配置专用且持久的Docker服务器,来加速Docker镜像的构建过程。该功能通过集中镜像构建到远程主机,显著减少了等待时间,提高了整体效率。经过测试,构建时间从24分钟54秒缩短至16秒,降幅高达98%。Docker Server通过提供具有一致缓存的持久Docker服务器来减少应用程序的构建时间。启用后,专用Docker服务器会配置持久存储,以维护Docker层缓存,从而处理多个并发Docker构建操作,所有构建都将从同一集中式缓存中受益。

🚀 AWS CodeBuild Docker Server通过提供持久的Docker服务器和集中的缓存,显著减少了Docker镜像的构建时间,经过测试,构建时间减少了98%。

⚙️ 启用Docker Server功能非常简单,只需在AWS CodeBuild控制台中选择“创建项目”,然后在“环境”部分的“其他配置”中,启用“为此项目启用Docker服务器”选项,并选择计算类型配置。

🐳 Docker Server支持x86(Linux)和ARM架构的构建,适用于所有提供AWS CodeBuild的AWS区域。详细的定价信息可以在AWS CodeBuild定价页面上找到。

💾 Docker Server通过维护构建之间的所有层,提供持久缓存,这对于具有许多层的大型复杂Docker镜像尤其有价值,显著提高了CI/CD管道中运行大量Docker构建的团队的吞吐量。

<section class="blog-post-content lb-rtxt"><table id="amazon-polly-audio-table"><tbody><tr><td id="amazon-polly-audio-tab"><p></p></td></tr></tbody></table><p>Starting today, you can use <a href="https://aws.amazon.com/codebuild/&quot;&gt;AWS CodeBuild</a> Docker Server capability to provision a dedicated and persistent Docker server directly within your CodeBuild project. With Docker Server capability, you can accelerate your Docker image builds by centralizing image building to a remote host, which reduces wait times and increases overall efficiency.</p><p>From my benchmark, with this Docker Server capability, I reduced the total building time by 98 percent, from 24 minutes and 54 seconds to 16 seconds. Here’s a quick look at this feature from my AWS CodeBuild projects.</p><p><img class="aligncenter size-full wp-image-95729 c4" src="https://d2908q01vomqb2.cloudfront.net/da4b9237bacccdf19c0760cab7aec4a8359010b0/2025/04/30/news-2025-codebuilddockerserver-rev-0.png&quot; alt="" width="2692" height="1035" /></p><p><a href="https://aws.amazon.com/codebuild/&quot;&gt;AWS CodeBuild</a> is a fully managed continuous integration service that compiles source code, runs tests, and produces software packages ready for deployment. Building Docker images is one of the most common use cases for CodeBuild customers, and the service has progressively improved this experience over time by releasing features such as <a href="https://docs.aws.amazon.com/codebuild/latest/userguide/build-caching.html&quot;&gt;Docker layer caching</a> and <a href="https://docs.aws.amazon.com/codebuild/latest/userguide/fleets.html&quot;&gt;reserved capacity features</a> to improve Docker build performance.</p><p>With the new Docker Server capability, you can reduce build time for your applications by providing a persistent Docker server with consistent caching. When enabled in a CodeBuild project, a dedicated Docker server is provisioned with persistent storage that maintains your Docker layer cache. This server can handle multiple concurrent Docker build operations, with all builds benefiting from the same centralized cache.</p><p><strong>Using AWS CodeBuild Docker Server</strong><br />Let me walk you through a demonstration that showcases the benefits with the new Docker Server capability.</p><p>For this demonstration, I’m building a complex, multi-layered Docker image based on the official <a href="https://github.com/aws/aws-codebuild-docker-images/tree/master&quot;&gt;AWS CodeBuild curated Docker images repository</a>, specifically the Dockerfile for building a <a href="https://github.com/aws/aws-codebuild-docker-images/tree/master/ubuntu/standard/5.0&quot;&gt;standard Ubuntu image</a>. This image contains numerous dependencies and tools required for modern continuous integration and continuous delivery (CI/CD) pipelines, making it a good example of the type of large Docker builds that development teams regularly perform.</p><pre class="language-dockerfile"># Copyright 2020-2024 Amazon.com, Inc. or its affiliates. All Rights Reserved.## Licensed under the Amazon Software License (the "License"). You may not use this file except in compliance with the License.# A copy of the License is located at## http://aws.amazon.com/asl/## or in the "license" file accompanying this file.# This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, express or implied.# See the License for the specific language governing permissions and limitations under the License.FROM public.ecr.aws/ubuntu/ubuntu:20.04 AS coreARG DEBIAN_FRONTEND="noninteractive"# Install git, SSH, Git, Firefox, GeckoDriver, Chrome, ChromeDriver, stunnel, AWS Tools, configure SSM, AWS CLI v2, env tools for runtimes: Dotnet, NodeJS, Ruby, Python, PHP, Java, Go, .NET, Powershell Core, Docker, Composer, and other utilitiesCOMMAND REDACTED FOR BREVITY# Activate runtime versions specific to image version.RUN n $NODE_14_VERSIONRUN pyenv global $PYTHON_39_VERSIONRUN phpenv global $PHP_80_VERSIONRUN rbenv global $RUBY_27_VERSIONRUN goenv global $GOLANG_15_VERSION# Configure SSHCOPY ssh_config /root/.ssh/configCOPY runtimes.yml /codebuild/image/config/runtimes.ymlCOPY dockerd-entrypoint.sh /usr/local/bin/dockerd-entrypoint.shCOPY legal/bill_of_material.txt /usr/share/doc/bill_of_material.txtCOPY amazon-ssm-agent.json /etc/amazon/ssm/amazon-ssm-agent.jsonENTRYPOINT ["/usr/local/bin/dockerd-entrypoint.sh"]</pre><p>This Dockerfile creates a comprehensive build environment with multiple programming languages, build tools, and dependencies – exactly the type of image that would benefit from persistent caching.</p><p>In the build specification (buildspec), I use the <code>docker buildx build .</code> command:</p><pre class="language-yaml">version: 0.2phases: build: commands: - cd ubuntu/standard/5.0 - docker buildx build -t codebuild-ubuntu:latest .</pre><p>To enable the Docker Server capability, I navigate to the AWS CodeBuild console and select <strong>Create project</strong>. I can also enable this capability when editing existing CodeBuild projects.</p><p><img class="aligncenter size-full wp-image-95616 c4" src="https://d2908q01vomqb2.cloudfront.net/da4b9237bacccdf19c0760cab7aec4a8359010b0/2025/04/28/news-2025-codebuilddockerserver-0.png&quot; alt="" width="3024" height="1716" /></p><p>I fill in all details and configuration. In the <strong>Environment</strong> section, I select <strong>Additional configuration</strong>.</p><p><img class="aligncenter wp-image-95730 size-full c4" src="https://d2908q01vomqb2.cloudfront.net/da4b9237bacccdf19c0760cab7aec4a8359010b0/2025/04/30/news-2025-codebuilddockerserver-rev-1.png&quot; alt="" width="2646" height="3256" /></p><p>Then, I scroll down and find <strong>Docker server configuration</strong> and select <strong>Enable docker server for this project</strong>. When I select this option, I can choose a compute type configuration for the Docker server. When I’m finished with the configurations, I create this project.</p><p><img class="aligncenter wp-image-95833 size-full c4" src="https://d2908q01vomqb2.cloudfront.net/da4b9237bacccdf19c0760cab7aec4a8359010b0/2025/05/03/news-2025-codebuilddockerserver-rev-6.png&quot; alt="" width="917" height="385" /></p><p>Now, let’s see the Docker Server capability in action.</p><p>The initial build takes approximately 24 minutes and 54 seconds to complete because it needs to download and compile all dependencies from scratch. This is expected for the first build of such a complex image.</p><p><img class="aligncenter size-full wp-image-95732 c4" src="https://d2908q01vomqb2.cloudfront.net/da4b9237bacccdf19c0760cab7aec4a8359010b0/2025/04/30/news-2025-codebuilddockerserver-rev-3.png&quot; alt="" width="2708" height="2071" /></p><p>For subsequent builds with no code changes, the build takes only 16 seconds and that shows 98% reduction in build time.</p><p><img class="aligncenter size-full wp-image-95733 c4" src="https://d2908q01vomqb2.cloudfront.net/da4b9237bacccdf19c0760cab7aec4a8359010b0/2025/04/30/news-2025-codebuilddockerserver-rev-4.png&quot; alt="" width="2696" height="2080" /></p><p>Looking at the logs, I can see that with Docker Server, most layers are pulled from the persistent cache:</p><p><img class="aligncenter wp-image-95734 size-full c4" src="https://d2908q01vomqb2.cloudfront.net/da4b9237bacccdf19c0760cab7aec4a8359010b0/2025/04/30/news-2025-codebuilddockerserver-rev-5.png&quot; alt="" width="2664" height="2548" /></p><p>The persistent caching provided by the Docker Server maintains all layers between builds, which is particularly valuable for large, complex Docker images with many layers. This demonstrates how Docker Server can dramatically improve throughput for teams running numerous Docker builds in their CI/CD pipelines.</p><p><strong>Additional things to know</strong><br />Here are a couple of things to note:</p><ul><li><strong>Architecture support</strong> – The feature is available for both x86 (Linux) and ARM builds.</li><li><strong>Pricing</strong> – To learn more about pricing for Docker Server capability, refer to the <a href="https://aws.amazon.com/codebuild/pricing/&quot;&gt;AWS CodeBuild pricing</a> page.</li><li><strong>Availability</strong> – This feature is available in all AWS Regions where AWS CodeBuild is offered. For more information about the AWS Regions where CodeBuild is available, see the <a href="https://aws.amazon.com/about-aws/global-infrastructure/regional-product-services/&quot;&gt;AWS Regions page</a>.</li></ul><p>You can learn more about the Docker Server feature in the <a href="https://docs.aws.amazon.com/codebuild/latest/userguide/sample-docker-server.html&quot;&gt;AWS CodeBuild documentation</a>.</p><p>Happy building! —</p><p><a href="https://linkedin.com/in/donnieprakoso&quot;&gt;Donnie Prakoso</a></p><hr /><p>How is the News Blog doing? Take this <a href="https://amazonmr.au1.qualtrics.com/jfe/form/SV_eyD5tC5xNGCdCmi&quot;&gt;1 minute survey</a>!</p><p><em>(This <a href="https://amazonmr.au1.qualtrics.com/jfe/form/SV_eyD5tC5xNGCdCmi&quot;&gt;survey&lt;/a&gt; is hosted by an external company. AWS handles your information as described in the <a href="https://aws.amazon.com/privacy/?trk=4b29643c-e00f-4ab6-ab9c-b1fb47aa1708&amp;amp;sc_channel=blog&quot;&gt;AWS Privacy Notice</a>. AWS will own the data gathered via this survey and will not share the information collected with survey respondents.)</em></p></section><aside id="Comments" class="blog-comments"><div data-lb-comp="aws-blog:cosmic-comments" data-env="prod" data-content-id="e3a990c3-4693-4e03-8693-45c739834061" data-title="Accelerate CI/CD pipelines with the new AWS CodeBuild Docker Server capability" data-url="https://aws.amazon.com/blogs/aws/accelerate-ci-cd-pipelines-with-the-new-aws-codebuild-docker-server-capability/&quot;&gt;&lt;p data-failed-message="Comments cannot be loaded… Please refresh and try again.">Loading comments…</p></div></aside>

Fish AI Reader

Fish AI Reader

AI辅助创作,多种专业模板,深度分析,高质量内容生成。从观点提取到深度思考,FishAI为您提供全方位的创作支持。新版本引入自定义参数,让您的创作更加个性化和精准。

FishAI

FishAI

鱼阅,AI 时代的下一个智能信息助手,助你摆脱信息焦虑

联系邮箱 441953276@qq.com

相关标签

AWS CodeBuild Docker Server CI/CD Docker镜像构建
相关文章