Part 1: CI/CD Pipeline Configuration

Create a free account on GitHub and then create a new repository on GitHub called cloudmart

cd challenge-day2/frontend
<Run GitHub steps>

Start by pushing the changes in the CloudMart application source code to GitHub

git status
git add -A
git commit -m "app sent to repo"
git push

Configure AWS CodePipeline

  1. Create a New Pipeline:

Configure AWS CodeBuild to Build the Docker Image

  1. Create a Build Project:
version: 0.2
phases:
  install:
    runtime-versions:
      docker: 20
  pre_build:
    commands:
      - echo Logging in to Amazon ECR...
      - aws --version
      - REPOSITORY_URI=$ECR_REPO
      **- aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws/l4c0j8h9**
  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:$CODEBUILD_RESOLVED_SOURCE_VERSION
  post_build:
    commands:
      - echo Build completed on `date`
      - echo Pushing the Docker image...
      - docker push $REPOSITORY_URI:latest
      - docker push $REPOSITORY_URI:$CODEBUILD_RESOLVED_SOURCE_VERSION
      - export imageTag=$CODEBUILD_RESOLVED_SOURCE_VERSION
      - printf '[{\\"name\\":\\"cloudmart-app\\",\\"imageUri\\":\\"%s\\"}]' $REPOSITORY_URI:$imageTag > imagedefinitions.json
      - cat imagedefinitions.json
      - ls -l

env:
  exported-variables: ["imageTag"]

artifacts:
  files:
    - imagedefinitions.json
    - cloudmart-frontend.yaml

  1. Add the AmazonElasticContainerRegistryPublicFullAccess permission to ECR in the service role

Configure AWS CodeBuild for Application Deployment

Create a Deployment Project: