-
Notifications
You must be signed in to change notification settings - Fork 5
/
buildspec.yml
32 lines (32 loc) · 1.68 KB
/
buildspec.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
---
version: 0.2
phases:
install:
commands:
- docker version
- curl -JLO https://github.com/docker/buildx/releases/download/v0.9.1/buildx-v0.9.1.linux-amd64
- mkdir -p ~/.docker/cli-plugins
- mv buildx-v0.9.1.linux-amd64 ~/.docker/cli-plugins/docker-buildx
- chmod a+rx ~/.docker/cli-plugins/docker-buildx
- docker run --privileged --rm public.ecr.aws/vend/tonistiigi/binfmt:latest --install all
pre_build:
commands:
- export CONTROLLER_IMG=$REPO_HOST/$CONTROLLER_REPO_NAME:$BRANCH_NAME.$(date +%Y-%m-%d.%H.%M.%S).$(echo $CODEBUILD_RESOLVED_SOURCE_VERSION | head -c 8)
- export AGENT_IMG=$REPO_HOST/$AGENT_REPO_NAME:$BRANCH_NAME.$(date +%Y-%m-%d.%H.%M.%S).$(echo $CODEBUILD_RESOLVED_SOURCE_VERSION | head -c 8)
- aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin $REPO_HOST
build:
commands:
- docker buildx create --use --name crossx
- export PLATFORMS=linux/arm64,linux/amd64
- export TARGETARCH=$(uname -m)
- cd controllers
- docker buildx build --push --platform $PLATFORMS --tag $CONTROLLER_IMG --tag $REPO_HOST/$CONTROLLER_REPO_NAME:$BRANCH_NAME .
- cd ../agent
- docker buildx build --push --platform $PLATFORMS --tag $AGENT_IMG --tag $REPO_HOST/$AGENT_REPO_NAME:$BRANCH_NAME --build-arg TARGETARCH=$TARGETARCH .
- cd ..
post_build:
commands:
- printf '[{"name":"core-controller","branchName":"$BRANCH_NAME","imageUri":"%s"}]' $CONTROLLER_REPO_NAME:$BRANCH_NAME > build.json
- printf '[{"name":"core-agent","branchName":"$BRANCH_NAME","imageUri":"%s"}]' $AGENT_REPO_NAME:$BRANCH_NAME > build.json
artifacts:
files: build.json