-
Notifications
You must be signed in to change notification settings - Fork 0
/
buildspec.yml
54 lines (48 loc) · 2.57 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
version: 0.2
env:
variables:
REPO_ECR_NAME: "blender-repo-ecr"
BASE_STACK_NAME: "BRENDER-STACK-"
phases:
install:
commands:
- yum -q install -y jq
- npm install -g aws-cdk
- echo $DOCKER_VERSION
- echo $BLENDER_VERSIONS
- echo Setting up docker
- nohup /usr/local/bin/dockerd --host=unix:///var/run/docker.sock --host=tcp://127.0.0.1:2375 --storage-driver=overlay2 &
- timeout 15 sh -c "until docker info; do echo .; sleep 1; done"
- aws ecr get-login-password --region $AWS_DEFAULT_REGION | docker login --username AWS --password-stdin $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com
pre_build:
commands:
- echo "Running pre-build commands"
- cdk bootstrap aws://${AWS_ACCOUNT_ID}/${AWS_DEFAULT_REGION}
- echo "Checking if ECR repository exists"
- aws ecr describe-repositories --repository-names $REPO_ECR_NAME || aws ecr create-repository --repository-name $REPO_ECR_NAME --region $AWS_DEFAULT_REGION
build:
commands:
- git clone https://github.com/Brender-Studio/brender-studio-cdk.git
- cd brender-studio-cdk/
- if [ $? -ne 0 ]; then echo "Failed to clone repository"; exit 1; fi
- ls -la
- chmod +x build_docker_images.sh
- ./build_docker_images.sh $REPO_ECR_NAME $BLENDER_VERSIONS $AWS_ACCOUNT_ID $AWS_DEFAULT_REGION || exit 1 # This will build the docker images and push them to ECR repository or exit if it fails
- cd aws_cdk
- ls -la
- npm install
- echo "Checking for g6 instance types in the region"
- G6_AVAILABLE=$(aws ec2 describe-instance-type-offerings --location-type availability-zone --filters Name=instance-type,Values=g6.* --region $AWS_DEFAULT_REGION --output json | jq '.InstanceTypeOfferings | length > 0')
- if [ "$G6_AVAILABLE" = "true" ]; then
echo "g6 instance types are available in the region";
export USE_G6=true;
else
echo "g6 instance types are NOT available in the region";
export USE_G6=false;
fi
post_build:
commands:
- export STACK_NAME="${BASE_STACK_NAME}${STACK_NAME}"
- echo $STACK_NAME
- echo $MAX_VCPUS
- cdk deploy --context stackName=$STACK_NAME --parameters ecrRepoName=$REPO_ECR_NAME --context blenderVersions=$BLENDER_VERSIONS --context isPrivate=$IS_PRIVATE --context account=${AWS_ACCOUNT_ID} --context region=${AWS_DEFAULT_REGION} --context maxvCpus=${MAX_VCPUS} --context spotBidPercentage=${SPOT_BID_PERCENTAGE} --context useG6Instances=${USE_G6} --region ${AWS_DEFAULT_REGION} --require-approval never;