Question 59:
You are working on a Jenkins continuous delivery pipeline for a Golang project. The pipeline uses AWS CodeBuild to build the Docker image and push it to an AWS ECR repository. You already have the Dockerfile, and now you need to create the buildspec.yml file for the CodeBuild project. The buildspec.yml file has several stages, including install, pre_build, build and post_build. Before the build stage, you should have already logged in to ECR. Which commands are suitable to be placed in the CodeBuild build stage?
Answer options:
A.build: commands: - $(aws ecr get-login --no-include-email --region $AWS_DEFAULT_REGION) - docker build -t $IMAGE_REPO_NAME:$IMAGE_TAG . - docker tag $IMAGE_REPO_NAME:$IMAGE_TAG - docker push $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/ $IMAGE_REPO_NAME:$IMAGE_TAG B. build: commands: - $(aws ecr get-login --no-include-email --region $AWS_DEFAULT_REGION) - docker build -t $IMAGE_REPO_NAME:$IMAGE_TAG . - docker tag $IMAGE_REPO_NAME:$IMAGE_TAG - docker run $REPOSITORY_URI:$IMAGE_TAG - docker push $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/ $IMAGE_REPO_NAME:$IMAGE_TAG C.build: commands: - docker build -t $IMAGE_REPO_NAME:$IMAGE_TAG . - docker tag $IMAGE_REPO_NAME:$IMAGE_TAG $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$IMAGE_REPO_NAME:$IMAGE_TAG - docker push $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/ $IMAGE_REPO_NAME:$IMAGE_TAG D. build: commands: - docker start $IMAGE_REPO_NAME:$IMAGE_TAG - docker build -t $IMAGE_REPO_NAME:$IMAGE_TAG . - docker tag $IMAGE_REPO_NAME:$IMAGE_TAG - docker run $IMAGE_REPO_NAME:$IMAGE_TAG - docker push $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/ $IMAGE_REPO_NAME:$IMAGE_TAG