Day 51 of #90DaysOfDevOps
What is CodeBuild?
- AWS CodeBuild is a fully managed build service in the cloud. CodeBuild compiles your source code, runs unit tests, and produces artifacts that are ready to deploy. CodeBuild eliminates the need to provision, manage, and scale your build servers.
Task-1 :
Read about the Buildspec file for Codebuild.
create a simple index.html file in the CodeCommit Repository.
you have to build the index.html using the nginx server.
Task-2 :
- Add the buildspec.yaml file to CodeCommit Repository and complete the build process.
Task 1
Buildspec:
- A buildspec is a collection of build commands and related settings, in YAML format, that CodeBuild uses to run a build. You can include a buildspec as part of the source code or you can define a buildspec when you create a build project. For information about how a build spec works, see How CodeBuild works.
- If you include a buildspec as part of the source code, by default, the buildspec file must be named
buildspec.yml
and placed in the root of your source directory.
Create a simple index.html file in CodeCommit Repository
In the previous tutorial, I created a CodeCommit repository and I am going to upload the index.html file in it. You can refer to that blog here.
Push the changes.
You have to build the index.html using nginx server
Create a buildspec.yaml file.
version: 0.2 phases: install: commands: - echo Updating... - sudo apt update -y - echo Installing NGINX server - sudo apt-get install -y nginx build: commands: - echo Entered the build phase... - echo Copying index file to the nginx... - cp index.html /var/www/html/ artifacts: files: - /var/www/html/index.html
Add buildspec.yaml file to CodeCommit Repository and complete the build process.
Go to the CodeBuild and create a project.
Fill up the form.
Enter the project name,
Source provider - codecommit,
Select the repository,
Branch - master,
Operating system - Ubuntu,
Runtime(s),
Image
Build specifications - use a buildspec file
Start the build.
Build success.
Add artifacts to a CodeBuild project and store them in an S3 bucket.
Create a bucket.
a bucket is successfully created.
Go back to the
CodeBuild
and click onedit
then chooseArtifacts
.Choose type S3 and the bucket. Click update.
Try to start the build, it will update the S3 bucket with the specified artifacts in buildspec.yaml.
After success of the build, check S3.
You can also open the html file.