Setup buildspec.yml

Replace REPOSITORY_URL_FROM_ECR in the pre_build commands with the ECR URL we created in the previous step.

version: 0.2

phases:
  pre_build:
    commands:
      - echo Start login ECR on `date`
      - echo Login to Amazon ECR
      - $(aws ecr get-login --region eu-west-1 --no-include-email)
      - REPOSITORY_URI=<FILL IN REPOSITORY URL>
      - IMAGE_TAG=${TAG_TARGET:=production}	
  build:
    commands:
      - echo Start building on `date`
      - echo Building the Docker image...          
      - docker build -t $REPOSITORY_URI:$IMAGE_TAG .
      - docker tag $REPOSITORY_URI:$IMAGE_TAG $REPOSITORY_URI:$CODEBUILD_RESOLVED_SOURCE_VERSION
  post_build:
    commands:
      - echo Build completed on `date`
      - echo Pushing the Docker images...
      - docker push $REPOSITORY_URI:$IMAGE_TAG
      - docker push $REPOSITORY_URI:$CODEBUILD_RESOLVED_SOURCE_VERSION
      - echo Writing image definitions file...
      - printf '[{"name":"hello-world","imageUri":"%s"}]' $REPOSITORY_URI:$IMAGE_TAG > imagedefinitions.json
artifacts:
    files: imagedefinitions.json
Last Updated: 3/6/2019, 9:19:51 AM