1+ version : 0.2
2+
3+ phases :
4+ install :
5+ runtime-versions :
6+ python : 3.8
7+ docker : 19
8+ pre_build :
9+ commands :
10+ - echo Pre-build started on `date`
11+ - echo Installing dependencies...
12+ - curl -LO http://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh
13+ - bash Miniconda3-latest-Linux-x86_64.sh -bfp /miniconda3
14+ - export PATH=/miniconda3/bin:${PATH}
15+ - conda install python=3.8
16+ - conda update -y conda
17+ - python3 -m pip install pip==20.1
18+ - python3 -m pip install .[test]
19+ build :
20+ commands :
21+ - echo Build started on `date`
22+ - echo Docker login...
23+ - docker login -u $dockerhub_username -p $dockerhub_password
24+ - echo Building the Docker image...
25+ - docker build -t xgboost-container-base:$FRAMEWORK_VERSION-cpu-py3 -f docker/$FRAMEWORK_VERSION/base/Dockerfile.cpu .
26+ - python3 setup.py bdist_wheel --universal
27+ - docker build -t preprod-xgboost-container:$FRAMEWORK_VERSION-cpu-py3 -f docker/$FRAMEWORK_VERSION/final/Dockerfile.cpu .
28+ - printf "FROM preprod-xgboost-container:$FRAMEWORK_VERSION-cpu-py3\nADD . /app\nWORKDIR /app\nRUN python3 -m pip install .[test]" > Dockerfile.test
29+ - docker build -t test-xgboost-container -f Dockerfile.test .
30+ - echo Running tox...
31+ - docker run --rm -t test-xgboost-container sh -c 'tox -e ALL'
32+ - echo Running container tests...
33+ - pytest test/integration/local --docker-base-name preprod-xgboost-container --tag $FRAMEWORK_VERSION-cpu-py3 --py-version 3 --framework-version $FRAMEWORK_VERSION
34+ - docker tag preprod-xgboost-container:$FRAMEWORK_VERSION-cpu-py3 $SM_ALPHA.dkr.ecr.us-west-2.amazonaws.com/sagemaker-xgboost:$FRAMEWORK_VERSION-cpu-py3
35+ - docker tag preprod-xgboost-container:$FRAMEWORK_VERSION-cpu-py3 $SM_ALPHA.dkr.ecr.us-west-2.amazonaws.com/sagemaker-xgboost:$FRAMEWORK_VERSION
36+ post_build :
37+ commands :
38+ - echo Build completed on `date`
39+ - |
40+ case $CODEBUILD_WEBHOOK_EVENT in
41+ PULL_REQUEST_MERGED)
42+ echo Logging in to Amazon ECR...
43+ $(aws ecr get-login --no-include-email --region $AWS_DEFAULT_REGION)
44+ echo Pushing the Docker image...
45+ docker push $SM_ALPHA.dkr.ecr.us-west-2.amazonaws.com/sagemaker-xgboost:$FRAMEWORK_VERSION-cpu-py3 | grep -v -E "[0-9]{12}.dkr.ecr.\S+.amazonaws.com"
46+ docker push $SM_ALPHA.dkr.ecr.us-west-2.amazonaws.com/sagemaker-xgboost:$FRAMEWORK_VERSION | grep -v -E "[0-9]{12}.dkr.ecr.\S+.amazonaws.com"
47+ ;;
48+ PULL_REQUEST_CREATED | PULL_REQUEST_UPDATED | PULL_REQUEST_REOPENED)
49+ echo Logging in to Amazon ECR...
50+ $(aws ecr get-login --no-include-email --region $AWS_DEFAULT_REGION)
51+ echo Pushing the Docker image...
52+ # pushes test tag for manual verification, requires cleanup in ECR every once in a while though
53+ TEST_TAG=$SM_ALPHA.dkr.ecr.us-west-2.amazonaws.com/sagemaker-xgboost:${FRAMEWORK_VERSION}-cpu-py3-test
54+ docker tag preprod-xgboost-container:$FRAMEWORK_VERSION-cpu-py3 ${TEST_TAG}
55+ docker push ${TEST_TAG} | grep -v -E "[0-9]{12}.dkr.ecr.\S+.amazonaws.com"
56+ ;;
57+ *)
58+ echo Undefined behavior for webhook event type $CODEBUILD_WEBHOOK_EVENT
59+ ;;
60+ esac
0 commit comments