Skip to content

Commit

Permalink
fix docker build script (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
bellatoris authored and gavin-jeong committed Jan 16, 2025
1 parent a546495 commit a2f64b9
Showing 1 changed file with 46 additions and 10 deletions.
56 changes: 46 additions & 10 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,6 @@ jobs:

steps:
- checkout
- run:
name: build
command: |
BUILD_WITH_CONTAINER=1 make build_envoy
- aws-setup
- run:
name: Set environment
Expand All @@ -77,15 +73,33 @@ jobs:
ARCH=arm64
fi
echo "export ARCH=$ARCH" >> $BASH_ENV
- run:
name: build
command: |
set +e
docker manifest inspect $URI-$ARCH > /dev/null
if [ $? -eq 0 ]; then
echo "ECR already has an image for $URI. Skipping build since registry is immutable."
circleci-agent step halt
else
BUILD_WITH_CONTAINER=1 make build_envoy
fi
- run:
name: Extract build output
command: |
common/scripts/run.sh cp /work/bazel-bin/envoy .
mkdir $ARCH
cp envoy $ARCH/
docker build -t "$URI-$ARCH" .
docker push "$URI-$ARCH"
docker build -t $URI-$ARCH .
- run:
name: Export docker images
command: |
mkdir release_archive
docker save $URI-$ARCH | zstd > release_archive/release_$ARCH.tar.zst
- persist_to_workspace:
root: .
paths: release_archive
- store_artifacts:
path: envoy
merge_docker:
Expand All @@ -99,13 +113,33 @@ jobs:
command: |
echo 'export REPOSITORY=mesg/istio/proxyv2' >> $BASH_ENV
echo 'export URI=$ECR_HOST/$REPOSITORY:$CIRCLE_TAG' >> $BASH_ENV
- attach_workspace:
at: /tmp/workspace
- run:
name: Build docker image
command: |
docker pull $URI-amd64
docker pull $URI-arm64
docker manifest create $URI $URI-amd64 $URI-arm64
docker manifest push $URI
set +e
docker manifest inspect $URI > /dev/null
if [ $? -eq 0 ]; then
echo "ECR already has an image for $URI. Skipping build since registry is immutable."
else
docker manifest inspect $URI-amd64 > /dev/null
if [ $? -ne 0 ]; then
zstdcat /tmp/workspace/release_archive/release_amd64.tar.zst | docker load
docker push $URI-amd64
fi
docker manifest inspect $URI-arm64 > /dev/null
if [ $? -ne 0 ]; then
zstdcat /tmp/workspace/release_archive/release_arm64.tar.zst | docker load
docker push $URI-arm64
fi
docker pull $URI-amd64
docker pull $URI-arm64
docker manifest create $URI $URI-amd64 $URI-arm64
docker manifest push $URI
fi
commands:
aws-setup:
Expand All @@ -120,6 +154,8 @@ commands:
fi
mkdir -p ~/.docker
echo '{ "credsStore": "ecr-login" }' > ~/.docker/config.json
sudo apt install -y zstd
- run:
name: Setup AWS credentials
command: |
Expand Down

0 comments on commit a2f64b9

Please sign in to comment.