Skip to content
This repository was archived by the owner on Aug 7, 2025. It is now read-only.

Commit c7c5076

Browse files
authored
CodeBuild: document custom builds images & better clarify limitations (#1789)
1 parent 687c21f commit c7c5076

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

content/en/references/configuration.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ This section covers configuration options that are specific to certain AWS servi
130130
| Variable | Example Values | Description |
131131
| - | - | - |
132132
| `CODEBUILD_REMOVE_CONTAINERS` | `0`\|`1` (default) | Remove Docker containers associated with a CodeBuild build tasks after execution. Disabling this and dumping container logs might help with troubleshooting failing builds. |
133+
| `CODEBUILD_ENABLE_CUSTOM_IMAGES` | `0` (default) \|`1` | Enable the usage of arbitrary CodeBuild build images. By default, all the builds are executed in a Amazon Linux 2023 container. |
133134

134135
### CodePipeline
135136

content/en/user-guide/aws/codebuild/index.md

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -332,8 +332,8 @@ $ awslocal codebuild create-project --cli-input-json file://create-project.json
332332
You have now created a CodeBuild project called `codebuild-demo-project` that uses the S3 buckets you just created as source and artifact.
333333

334334
{{< callout >}}
335-
LocalStack does not allow to customize the build environment.
336-
Depending on the host architecture, the build will be executed an Amazon Linux container, version `3.0.x` and `5.0.x`, respectively for the ARM and the x86 architecture.
335+
By default, LocalStack runs the all the builds in a Amazon Linux Container, ignoring the image provided in the `environment` parameter.
336+
See the [Build Environments](#build-environments) section for more details.
337337
{{< /callout >}}
338338

339339
### Run the build
@@ -369,8 +369,29 @@ Once the build is completed, you can verify that the JAR artifact has been uploa
369369
$ awslocal s3 ls://codebuild-demo-output
370370
{{< /command >}}
371371

372+
## Build Environments
373+
374+
LocalStack does not offer out-of-the-box all the build environments provided by AWS CodeBuild.
375+
By default, all the builds are executed in a Amazon Linux 2023 image (`public.ecr.aws/codebuild/amazonlinux-x86_64-standard:5.0` and `public.ecr.aws/codebuild/amazonlinux-aarch64-standard:3.0` for x86 and ARM, respectively).
376+
You can overcome this limitation by activating the `CODEBUILD_ENABLE_CUSTOM_IMAGES` environment variable.
377+
378+
AWS shares the Dockerfiles of official AWS CodeBuild curated Docker images in a dedicated [GitHub repository](https://github.com/aws/aws-codebuild-docker-images).
379+
For instance, let us assume you want to run your builds on the Ubuntu `7.0` standard image.
380+
381+
First, you have to build the image as follows:
382+
{{< command >}}
383+
$ git clone https://github.com/aws/aws-codebuild-docker-images.git
384+
$ cd aws-codebuild-docker-images
385+
$ cd ubuntu/standard/7.0
386+
$ docker build -t aws/codebuild/standard:7.0 .
387+
{{< /command >}}
388+
389+
Then, start LocalStack with `CODEBUILD_ENABLE_CUSTOM_IMAGES=1`.
390+
Finally, you can use the create image name, i.e., `aws/codebuild/standard:7.0` in the environment reference when you create you CodeBuild project.
391+
372392
## Limitations
373393

374394
- CodeBuild currently only supports S3, NO_SOURCE, and CODEPIPELINE as [project source](https://docs.aws.amazon.com/codebuild/latest/APIReference/API_ProjectSource.html).
375-
- CodeBuild only uses Amazon Linux as the build environment for a build project.
395+
- Custom build environments needs to have `bash` installed to properly work in LocalStack.
396+
- Environment variables in the `buildspec` are currently not supported.
376397
- Communication with the LocalStack container within the build environment is possible only via the host network, by using the Gateway IP address (typically 172.17.0.1) or `host.docker.internal` if running on MacOS.

0 commit comments

Comments
 (0)