AWS CodeBuild
What is AWS CodeBuild?
● Build service in cloud, member of AWS Developer Tools
● Serverless and fully-managed by AWS
● Scalable Automatically scales on demand
● Cost-effective. You pay only for the minutes you builds projects consume
● It acts as a command line in your pipelines
● It uses Docker Container to launch your build environment
● You can use the Docker images CodeBuild provides as well as the images on
the Docker Hub and Amazon ECR
● CodeBuild provides standard images for Ubuntu, Amazon Linux 2 and
Windows server core
AWS CodeBuild Component
Buildspec:
● YAML file containing your commands and runtime environment settings
● It can be provided as a file with the source code
● It can also be defined during the project creation on AWS CodeBuild Console
Buildspec.yml sample file
version: 0.2
phases:
pre_build:
commands:
- echo Logging in to Amazon ECR...
- ECR_LOGIN=$(aws ecr get-login-password --region $AWS_DEFAULT_REGION)
- echo $ECR_LOGIN | docker login -u AWS --password-stdin XXXXXX.dkr.ecr.ap-south-1.amazonaws.com
- REPOSITORY_URI=XXXXX.dkr.ecr.ap-south-1.amazonaws.com/reactrepository
- COMMIT_HASH=$(echo $CODEBUILD_RESOLVED_SOURCE_VERSION | cut -c 1-7)
- IMAGE_TAG=build-$(echo $CODEBUILD_BUILD_ID | awk -F":" '{print $2}')
build:
commands:
- echo Build started on `date`
- echo Building the Docker image...
- docker build -t $REPOSITORY_URI:latest .
- docker tag $REPOSITORY_URI:latest $REPOSITORY_URI:$IMAGE_TAG
post_build:
commands:
- echo Pushing the Docker image to Amazon ECR...
- docker push $REPOSITORY_URI
Thank
You

AWS CodeBuild presented by Techserverglobal

  • 1.
  • 2.
    What is AWSCodeBuild? ● Build service in cloud, member of AWS Developer Tools ● Serverless and fully-managed by AWS ● Scalable Automatically scales on demand ● Cost-effective. You pay only for the minutes you builds projects consume ● It acts as a command line in your pipelines ● It uses Docker Container to launch your build environment ● You can use the Docker images CodeBuild provides as well as the images on the Docker Hub and Amazon ECR ● CodeBuild provides standard images for Ubuntu, Amazon Linux 2 and Windows server core
  • 3.
    AWS CodeBuild Component Buildspec: ●YAML file containing your commands and runtime environment settings ● It can be provided as a file with the source code ● It can also be defined during the project creation on AWS CodeBuild Console
  • 4.
    Buildspec.yml sample file version:0.2 phases: pre_build: commands: - echo Logging in to Amazon ECR... - ECR_LOGIN=$(aws ecr get-login-password --region $AWS_DEFAULT_REGION) - echo $ECR_LOGIN | docker login -u AWS --password-stdin XXXXXX.dkr.ecr.ap-south-1.amazonaws.com - REPOSITORY_URI=XXXXX.dkr.ecr.ap-south-1.amazonaws.com/reactrepository - COMMIT_HASH=$(echo $CODEBUILD_RESOLVED_SOURCE_VERSION | cut -c 1-7) - IMAGE_TAG=build-$(echo $CODEBUILD_BUILD_ID | awk -F":" '{print $2}') build: commands: - echo Build started on `date` - echo Building the Docker image... - docker build -t $REPOSITORY_URI:latest . - docker tag $REPOSITORY_URI:latest $REPOSITORY_URI:$IMAGE_TAG post_build: commands: - echo Pushing the Docker image to Amazon ECR... - docker push $REPOSITORY_URI
  • 6.