version: 0.2 phases: build: commands: - docker login -u AWS -p $(aws ecr get-login-password --region $AWS_REGION) $ECR_ENDPOINT - docker pull $ECR_IMAGE_URL:$PREVIOUS_STAGE_NAME - docker tag $ECR_IMAGE_URL:$PREVIOUS_STAGE_NAME $ECR_IMAGE_URL:$STAGE_NAME - docker push $ECR_IMAGE_URL:$STAGE_NAME post_build: on-failure: CONTINUE commands: - aws ecs update-service --service $SERVICE_NAME --cluster $CLUSTER_ARN --force-new-deployment - aws ecs wait services-stable --service $SERVICE_NAME --cluster $CLUSTER_ARN finally: - aws cloudfront create-invalidation --distribution-id $DISTRIBUTION_ID --paths "/*"