Related Articles

10 Comments

  1. 1

    Immanuel Chui

    But, is this how people actually implement Docker CI/CD pipelines? I mean, every time a commit is pushed triggering the creation of a new image, the FROM instruction in the Dockerfile has to fetch the base image. And since CodeBuild is stateless, the base image can only live in a remote registry like Docker Hub or ECR. So if the base image is 500MB, that’s 500MB that has to be downloaded on every build.

    How do you manage that?

    Reply
    1. 1.1

      Onur SALK

      That’s how we do actually in our systems. Let other visitors comment also and see how they manage it.

      Reply
      1. 1.1.1

        Immanuel Chui

        Alright. I’ve been doing more investigations since and I’ll have to conclude that CodeBuild is optimal for some workflows, but suboptimal for others. Anyway, this was a comprehensive tutorial. Very AWSome blog.

        Reply
        1. 1.1.1.1

          Onur SALK

          Thanks for your comment!

          Reply
  2. 2

    sneha

    Getting error in pre_build phase:Error while executing command: $(aws ecr get-login –region $AWS_DEFAULT_REGION). Reason: exit status 255,please suggest me the solution for this and what kind of service roles do i need to attach it with wascodebuild-ecr service role.Thank you.

    Reply
    1. 2.1

      Onur SALK

      Hi Shena,

      Can you try with this:

      {
          "Version": "2012-10-17",
          "Statement": [
              {
                  "Effect": "Allow",
                  "Resource": [
                      "arn:aws:logs:eu-west-1:111122223333:log-group:/aws/codebuild/ECR",
                      "arn:aws:logs:eu-west-1:111122223333:log-group:/aws/codebuild/ECR:*"
                  ],
                  "Action": [
                      "logs:CreateLogGroup",
                      "logs:CreateLogStream",
                      "logs:PutLogEvents"
                  ]
              },
              {
                  "Effect": "Allow",
                  "Resource": [
                      "arn:aws:s3:::codepipeline-eu-west-1-*"
                  ],
                  "Action": [
                      "s3:PutObject",
                      "s3:GetObject",
                      "s3:GetObjectVersion"
                  ]
              },
              {
                  "Effect": "Allow",
                  "Resource": [
                      "arn:aws:codecommit:eu-west-1:111122223333:https://git-codecommit.eu-west-1.amazonaws.com/v1/repos/your-repo-name"
                  ],
                  "Action": [
                      "codecommit:GitPull"
                  ]
              },
              {
                  "Effect": "Allow",
                  "Resource": [
                      "arn:aws:s3:::your-bucket-name/*"
                  ],
                  "Action": [
                      "s3:PutObject"
                  ]
              }
          ]
      }
      
      Reply
      1. 2.1.1

        tw

        same issue. Getting error in pre_build phase:Error while executing command: $(aws ecr get-login –region $AWS_DEFAULT_REGION). Reason: exit status 255

        tried to change eu-west-1 to my region, also facing same error

        Reply
        1. 2.1.1.1

          tw

          managed to get it to run by granting ECS and EB permission to the role that codebuild uses. release pipeline successful completed, however, unable to access the app via EB URI. not sure if there’s something wrong with the container.

          Reply
  3. 3

    ALFcoin (@thattommyhall)

    Thanks for the tutorial, I found it very useful. Could you not just output the Dockerrun.aws.json rather than the whole code? (Saves renaming etc)

    Reply
    1. 3.1

      Onur SALK

      Hi Alfcoin, you can find the whole code here

      Reply

Leave a Reply to Immanuel Chui Cancel reply