DEV Community

Udoh Deborah
Udoh Deborah

Posted on

Day 51: CI/CD pipeline pt 2

What is CodeBuild?
• AWS CodeBuild is a fully managed continuous integration service.
• It compiles source code, runs tests, and produces deployable artifacts.
• No need to manage build servers — AWS handles scaling and infrastructure for you.
• Commonly used with CodeCommit, CodePipeline, and CodeDeploy.

Tasks for Day 51

Task 01 — Learn & Prep
A. Read about buildspec.yml:
• This file defines all the build commands and settings for CodeBuild.
• Written in YAML, placed at the root of your repo.

version: 0.2 phases: install: commands: - echo Installing dependencies... build: commands: - echo Build started on `date` - echo Compiling the application post_build: commands: - echo Build completed on `date` artifacts: files: - '**/*' 
Enter fullscreen mode Exit fullscreen mode

B. In your CodeCommit repo, create a simple index.html file:

<!DOCTYPE html> <html> <head> <title>Day 51 - CodeBuild Demo</title> </head> <body> <h1>Hello from AWS CodeBuild </h1> </body> </html> 
Enter fullscreen mode Exit fullscreen mode

C. Plan to build it using nginx server inside CodeBuild.

Task 02 — Build with CodeBuild
1. Create a buildspec.yml file in your repo:

version: 0.2 phases: install: runtime-versions: docker: 18 commands: - echo Installing Nginx... - yum install -y nginx build: commands: - echo Build started on `date` - mkdir -p /usr/share/nginx/html - cp index.html /usr/share/nginx/html/index.html post_build: commands: - echo Build completed on `date` - echo Artifacts ready for deployment artifacts: files: - index.html 
Enter fullscreen mode Exit fullscreen mode

D. Push changes to CodeCommit

git add index.html buildspec.yml git commit -m "Add index.html and buildspec for CodeBuild" git push origin main 
Enter fullscreen mode Exit fullscreen mode

In AWS Console → CodeBuild:

  • Create a new project.
  • Connect it to your CodeCommit repo.
  • Choose environment: Managed image → Amazon Linux 2 → Standard runtime.
  • Use the buildspec.yml you committed.
    1. Start the build → You should see the process install Nginx, copy index.html, and output artifacts.

Top comments (0)