5.9 KiB
CodeBuild
Floci implements the CodeBuild API — stored-state management plus real build execution inside Docker containers.
Protocol: JSON 1.1 — POST / with X-Amz-Target: CodeBuild_20161006.<Action>
ARN formats:
arn:aws:codebuild:<region>:<account>:project/<name>arn:aws:codebuild:<region>:<account>:report-group/<name>arn:aws:codebuild:<region>:<account>:token/<type>-<uuid>arn:aws:codebuild:<region>:<account>:build/<project>:<uuid>
Supported Operations (20 total)
Projects
| Operation | Notes |
|---|---|
CreateProject |
Stores project config; requires name, source.type, artifacts.type, environment, serviceRole |
UpdateProject |
Partial update — only supplied fields are modified |
DeleteProject |
Removes project by name |
BatchGetProjects |
Returns found projects and a projectsNotFound list |
ListProjects |
Returns project names in the region, with optional name, creation-time, or last-modified-time sorting |
Build Execution
| Operation | Notes |
|---|---|
StartBuild |
Launches a real Docker container using the project's image; runs buildspec phases (INSTALL, PRE_BUILD, BUILD, POST_BUILD); returns immediately with IN_PROGRESS status |
BatchGetBuilds |
Returns current build state; poll until buildComplete is true |
ListBuilds |
Returns all build IDs in the region, most recent first |
ListBuildsForProject |
Returns build IDs for a specific project |
StopBuild |
Signals a running build to stop; build transitions to STOPPED |
RetryBuild |
Starts a new build using the same config as a completed build; returns a new build record |
Report Groups
| Operation | Notes |
|---|---|
CreateReportGroup |
Stores report group config |
UpdateReportGroup |
Partial update by ARN |
DeleteReportGroup |
Removes report group by ARN |
BatchGetReportGroups |
Returns found report groups and a reportGroupsNotFound list |
ListReportGroups |
Returns all report group ARNs in the region |
Source Credentials
| Operation | Notes |
|---|---|
ImportSourceCredentials |
Stores server type and auth type; deduplicated by serverType+authType; token is accepted but not returned |
ListSourceCredentials |
Returns stored credential metadata (no tokens) |
DeleteSourceCredentials |
Removes source credentials by ARN |
Images
| Operation | Notes |
|---|---|
ListCuratedEnvironmentImages |
Returns a static list of standard CodeBuild images for AL2 and Ubuntu |
Build Execution Model
Each StartBuild call:
- Pulls the project's Docker image (e.g.
public.ecr.aws/docker/library/alpine:latest) - Starts a container with the working directories pre-created
- Injects source files into the container via
docker cp(NO_SOURCEbuilds skip this step) - Executes buildspec phases sequentially inside the container via
docker exec - Streams phase output to CloudWatch Logs under
/aws/codebuild/<project> - Extracts artifact files from the container via
docker cpand uploads them to S3 ifartifacts.type=S3 - Marks the build complete with
SUCCEEDED,FAILED, orSTOPPED
Source injection and artifact extraction both use the Docker API's archive copy endpoints — no bind mounts are required. This works correctly when Floci itself runs inside a Docker container (Docker-in-Docker).
VPC (vpcConfig)
CodeBuild runs a build of a project with a vpcConfig with a network interface in one of the project's subnets. Floci puts the build container on that VPC's Docker network, at an address leased from the first subnet, before the first phase runs, the way it places EC2 instances, VPC-configured Lambda functions and MWAA environments, so a build reaches a database or anything else in the VPC by its private IP. The container keeps the network it was created on as well. A subnet EC2 does not know, or FLOCI_SERVICES_EC2_VPC_NETWORKS_ENABLED=false, leaves it there alone. Security groups are not enforced, as for EC2. While a build runs, DeleteSubnet refuses its subnet and DeleteVpc its VPC (DependencyViolation), as the build's network interface does on AWS; a project's vpcConfig alone holds none. BatchGetBuilds returns the project's vpcConfig on each build.
Buildspec Support
Floci parses the buildspec.yml embedded in the project or provided via buildspecOverride. Supported fields:
phases—install,pre_build,build,post_buildcommand listsartifacts.files— list of file patterns to collect; supports**/*glob, specific filenames, and path patternsartifacts.base-directory— base directory for artifact collection (default:$CODEBUILD_SRC_DIR)
Artifact Upload
When artifacts.type=S3, collected files are uploaded to the configured S3 bucket. The bucket must exist (created via CreateBucket). File paths in S3 match the relative path from the artifact base directory.
Configuration
| Variable | Default | Description |
|---|---|---|
FLOCI_SERVICES_CODEBUILD_ENABLED |
true |
Enable or disable the service |
CLI Examples
# Create a project with S3 artifacts
aws --endpoint-url http://localhost:4566 codebuild create-project \
--name my-project \
--source type=NO_SOURCE \
--artifacts type=S3,location=my-bucket \
--environment type=LINUX_CONTAINER,image=public.ecr.aws/docker/library/alpine:latest,computeType=BUILD_GENERAL1_SMALL \
--service-role arn:aws:iam::000000000000:role/codebuild-role
# Start a build with inline buildspec
aws --endpoint-url http://localhost:4566 codebuild start-build \
--project-name my-project \
--buildspec-override 'version: 0.2
phases:
build:
commands:
- echo hello > output.txt
artifacts:
files:
- output.txt'
# Poll until complete
aws --endpoint-url http://localhost:4566 codebuild batch-get-builds --ids <build-id>
# List all builds
aws --endpoint-url http://localhost:4566 codebuild list-builds
# List curated images
aws --endpoint-url http://localhost:4566 codebuild list-curated-environment-images