Skip to content

Commit c979201

Browse files
mabundayMark Bunday
and
Mark Bunday
authored
Fix buildspec.yml tagging in PULL_REQUEST_MERGED (#130)
Co-authored-by: Mark Bunday <[email protected]>
1 parent 645cfa7 commit c979201

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

ci/buildspec.yml

+11-8
Original file line numberDiff line numberDiff line change
@@ -25,34 +25,37 @@ phases:
2525
- pip install wheel setuptools
2626
- python setup.py bdist_wheel
2727
- echo Building final container...
28-
- docker build -t preprod-sklearn:$FRAMEWORK_VERSION-cpu-py3 -f docker/$FRAMEWORK_VERSION/final/Dockerfile.cpu .
28+
- FINAL_IMAGE=preprod-sklearn:${FRAMEWORK_VERSION}-cpu-py3
29+
- docker build -t ${FINAL_IMAGE} -f docker/$FRAMEWORK_VERSION/final/Dockerfile.cpu .
2930
- echo Building test container...
30-
- printf "FROM preprod-sklearn:$FRAMEWORK_VERSION-cpu-py3\nADD . /app\nWORKDIR /app\nRUN python3 -m pip install .[test]" > Dockerfile.test
31+
- printf "FROM ${FINAL_IMAGE}\nADD . /app\nWORKDIR /app\nRUN python3 -m pip install .[test]" > Dockerfile.test
3132
- docker build -t test-sklearn -f Dockerfile.test .
3233
- echo Running tox...
3334
- docker run --rm --entrypoint /bin/bash test-sklearn -c "tox -e ALL"
3435
- echo Running container tests...
3536
- pytest test/integration --docker-base-name preprod-sklearn --tag $FRAMEWORK_VERSION-cpu-py3 --py-version 3 --framework-version $FRAMEWORK_VERSION
37+
- FINAL_URI=${SM_ALPHA}.dkr.ecr.us-west-2.amazonaws.com/sagemaker-scikit-learn:${FRAMEWORK_VERSION}
3638
post_build:
3739
commands:
3840
- echo Build completed on `date`
3941
- |
4042
case $CODEBUILD_WEBHOOK_EVENT in
4143
PULL_REQUEST_MERGED)
44+
docker tag ${FINAL_IMAGE} ${FINAL_URI}-cpu-py3
45+
docker tag ${FINAL_IMAGE} ${FINAL_URI}
4246
echo Logging in to Amazon ECR...
4347
$(aws ecr get-login --no-include-email --region $AWS_DEFAULT_REGION)
4448
echo Pushing the Docker image...
45-
docker push $SM_ALPHA.dkr.ecr.us-west-2.amazonaws.com/sagemaker-scikit-learn:$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-scikit-learn:$FRAMEWORK_VERSION | grep -v -E "[0-9]{12}.dkr.ecr.\S+.amazonaws.com"
49+
docker push ${FINAL_URI}-cpu-py3 | grep -v -E "[0-9]{12}.dkr.ecr.\S+.amazonaws.com"
50+
docker push ${FINAL_URI} | grep -v -E "[0-9]{12}.dkr.ecr.\S+.amazonaws.com"
4751
;;
4852
PULL_REQUEST_CREATED | PULL_REQUEST_UPDATED | PULL_REQUEST_REOPENED)
53+
docker tag ${FINAL_IMAGE} ${FINAL_URI}-cpu-py3-test
4954
echo Logging in to Amazon ECR...
5055
$(aws ecr get-login --no-include-email --region $AWS_DEFAULT_REGION)
5156
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-scikit-learn:${FRAMEWORK_VERSION}-cpu-py3-test
54-
docker tag preprod-sklearn:$FRAMEWORK_VERSION-cpu-py3 ${TEST_TAG}
55-
docker push ${TEST_TAG} | grep -v -E "[0-9]{12}.dkr.ecr.\S+.amazonaws.com"
57+
# Push test tag for manual verification. Requires cleanup in ECR occasionally
58+
docker push ${FINAL_URI}-cpu-py3-test | grep -v -E "[0-9]{12}.dkr.ecr.\S+.amazonaws.com"
5659
;;
5760
*)
5861
echo Undefined behavior for webhook event type $CODEBUILD_WEBHOOK_EVENT

0 commit comments

Comments
 (0)