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 own build servers.
Task-01 :
Read about the Buildspec file for Codebuild.
A Buildspec file is a YAML file that defines the build process for your CodeBuild project. It contains a series of commands that CodeBuild will execute to build and package your application.
Create a simple index.html file in the CodeCommit Repository.
you have to build the index.html using nginx server
Create a code commit repository
Copy clone HTTPS URL
In git bash, clone the repository to your local machine using the git clone command.
Inside the code commit repository create an index.html file
Save the file and commit the changes to the repository using the git add and git commit commands.
git commit -m "commit message"
Push the changes to the repository using the git push command.
git push origin master
You have a simple index.html file in your CodeCommit repository
Task-02 :
Add buildspec.yaml file to CodeCommit Repository and complete the build process.
Create a Buildspec file to build the file using an nginx server.
Below are the functions of each build step:
The version of the Buildspec syntax we're using is stated as version: 0.2.
Phases: This lists the stages of construction for our project.
install: utilizes the apt-get package manager to install nginx on the built environment.
build Places a copy of the index.html file in the nginx default web root directory.
post build: If additional nginx settings are required, it is done.
Indicates where the index.html file should be included in the build artifact.
With the git add and git commit commands, you can save the file and add the modifications to the repository.
Push the changes to the code commit repository
You have two files in your CodeCommit repository: buildspec.yml and index.html.
Create build project:
Go to the CodeBuild service. Click the "Create build project" button
Choose AWS CodeCommit as the source provider in the source area, then choose the repository you previously created and branch master.
Choose "Use a buildspec file" in the "Buildspec" section when creating a new service role.
Click "Create build project" to create your project.
The project was successfully created.
To begin a fresh build, click the "Start construction" button.
Verify the status of the successful build.
To include artifacts and store them in an S3 bucket as part of a CodeBuild project.
Choose "Artifacts" under "edit" after clicking.
First, create an S3 bucket.
Choose the Amazon S3 type and the bucket name you created in the previous step under Artifacts.
Choose "Update artifacts."
To begin a new build after updating artifacts, click the "Start build" button once more.
The built-in S3 bucket location will receive the artifacts after the build is finished.
The path of the file, which is /var/www/html/index.html, is specified in the artifacts phase of the buildspec.yml file. You can verify that the s3 bucket has folders and an index.html file.
Click on 'index.html' file, below you can see properties of file.
Click on 'open' on right-hand side.
Happy Learning!