main
sh 34 lines 933 Bytes
Raw
1 #!/bin/bash
2 set -e
3
4 if [[ $# -lt 3 ]]; then
5 echo "Usage: $0 <registry> <repo> <commit>"
6 exit 1
7 fi
8
9 REGISTRY=$1
10 REPO=$2
11 BUILDKITE_COMMIT=$3
12 IMAGE="$REGISTRY/$REPO:$BUILDKITE_COMMIT-xpu"
13
14 # authenticate with AWS ECR
15 aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin "$REGISTRY" || true
16 aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin 936637512419.dkr.ecr.us-east-1.amazonaws.com || true
17
18 # skip build if image already exists
19 if docker manifest inspect "$IMAGE" &> /dev/null; then
20 echo "Image found"
21 else
22 echo "Image not found, proceeding with build..."
23 # build
24 docker build \
25 --file docker/Dockerfile.xpu \
26 --build-arg max_jobs=16 \
27 --build-arg buildkite_commit="$BUILDKITE_COMMIT" \
28 --tag "$IMAGE" \
29 --progress plain .
30 # push
31 docker push "$IMAGE"
32 fi
33
34 .buildkite/scripts/annotate-image-build.sh "$IMAGE"