-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathbuildspec-private-repo.yml
77 lines (73 loc) · 2.95 KB
/
buildspec-private-repo.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
version: 0.2
env:
shell: bash
exported-variables:
- BSS_IMAGE_ASSET_REPOSITORY_NAME
- BUILD_VERSION
- CN_ASSETS
- GLOBAL_ASSETS
- ECR_REPOS
- CN_ECR_REPOS
- TAG_NUMBER
phases:
install:
runtime-versions:
nodejs: 18
commands:
- echo "nothing to do in install"
pre_build:
commands:
- cd infrastructure
- export BSS_IMAGE_ASSET_REPOSITORY_NAME='stable-diffusion-aws-extension'
- export TAG_NAME=$(curl -s https://api.github.com/repos/awslabs/stable-diffusion-aws-extension/tags | jq -r '.[0].name')
# Retry logic for fetching TAG_NAME
- |-
MAX_RETRIES=5
RETRY_COUNT=0
until [[ ! -z "$TAG_NAME" || $RETRY_COUNT -eq $MAX_RETRIES ]]
do
export TAG_NAME=$(curl -s https://api.github.com/repos/awslabs/stable-diffusion-aws-extension/tags | jq -r '.[0].name')
if [[ -z "$TAG_NAME" ]]; then
let RETRY_COUNT=RETRY_COUNT+1
echo "TAG_NAME is empty, retrying ($RETRY_COUNT/$MAX_RETRIES)..."
sleep 5 # wait for 5 seconds before retrying
fi
done
if [[ -z "$TAG_NAME" ]]; then
echo "Failed to fetch TAG_NAME after $MAX_RETRIES attempts."
exit 1
fi
- export BUILD_VERSION=${TAG_NAME}-${CODEBUILD_RESOLVED_SOURCE_VERSION:0:7}
- export CN_ASSETS='cn/'
- export TAG_NUMBER="${TAG_NAME#v}"
- |-
set -euxo pipefail
__dir="${CODEBUILD_SRC_DIR}/deployment"
function join_by { local IFS="$1"; shift; echo "$*"; }
export CN_ECR_REPOS=$(join_by , `cat "${__dir}/cn-ecr-repos"`)
- export GLOBAL_ASSETS='custom-domain/,default/'
build:
commands:
- echo "Starting build the public ECR"
- cd ../build_scripts
- chmod +x ./build_and_push_inference_private.sh
- json_output=$(aws sts assume-role --role-arn "$AWS_ASSET_PUBLISH_ROLE" --role-session-name "asset-publishing-role" --duration-seconds "3600" 2>&1)
- set +x
- export AWS_ACCESS_KEY_ID=$(echo "${json_output}" | jq --raw-output ".Credentials[\"AccessKeyId\"]")
- export AWS_SECRET_ACCESS_KEY=$(echo "${json_output}" | jq --raw-output ".Credentials[\"SecretAccessKey\"]")
- export AWS_SESSION_TOKEN=$(echo "${json_output}" | jq --raw-output ".Credentials[\"SessionToken\"]")
- echo "BUILD VERSION is ${BUILD_VERSION}"
- echo "./build_and_push_inference_private.sh Dockerfile.inference.from_scratch esd-inference dev ${REGION} ${BUILD_VERSION} ${CODEBUILD_RESOLVED_SOURCE_VERSION}"
- ./build_and_push_inference_private.sh Dockerfile.inference.from_scratch esd-inference dev ${REGION} ${BUILD_VERSION} ${CODEBUILD_RESOLVED_SOURCE_VERSION}
- unset AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY AWS_SESSION_TOKEN
- set -x
artifacts:
files:
- deployment/**/*
- infrastructure/**/*
- middleware_api/**/*
- .gitignore
- sonar-project.properties
- buildspec.yml
- CHANGELOG.md
- .cfnnag_*