Automated Build Pipeline

Automated Build Pipeline

Spring Application Deployed with Kubernetes

Step by step building an application using Spring Boot and deployed via Docker on Kubernetes with Helm

full course
  1. Setup: IDE and New Project
  2. Create the Data Repository
  3. Building a Service Layer
  4. Create a REST Controller
  5. Logging, Tracing and Error Handling
  6. Documentation and Code Coverage
  7. Database as a Service
  8. Containerize the Service With Docker
  9. Docker Registry
  10. Automated Build Pipeline
  11. Helm for Deployment
  12. Setting up a Kubernetes Cluster
  13. Automating Deployment (for CICD)
  14. System Design
  15. Messaging and Event Driven Design
  16. Web UI with React
  17. Containerizing our UI
  18. UI Build Pipeline
  19. Put the UI in to Helm
  20. Creating an Ingress in Kubernetes
  21. Simplify Deployment
  22. Conclusion and Review

Lets set up automated build so that we can generate a docker image when a change hits master.

Build the Pipeline

Go in to codefresh and choose Projects. Create a new project in the top right. Call it medium. Click on create pipeline. Call the pipeline medium-customer and choose our git repository from github. In the pipeline editor, add this yaml:

# More examples of Codefresh YAML can be found at
# https://codefresh.io/docs/docs/yaml-examples/examples/
version: "1.0"
# Stages can help you organize your steps in stages
stages:
  - "clone"
  - "build"
  - "push"
steps:
  Clone:
      title: "Cloning repository"
      type: "git-clone"
      repo: "https://github.com/brianrook/medium-customer"
      revision: "master"
      stage: "clone"
  PrintFileList:
      title: 'Listing files'
      stage: "clone"
      image: alpine:latest
      commands:
          - 'ls -l'
  BuildJar:
      title: Create Jar
      stage: "build"
      image: 'maven:3.6.3-jdk-11'
      commands:
        - mvn -Dmaven.repo.local=/codefresh/volume/m2_repository clean package
      working_directory: '/codefresh/volume/medium-customer'
  BuildImage:
      title: Building Docker Image
      type: build
      stage: build
      image_name: medium/medium-customer
      working_directory: '/codefresh/volume/medium-customer'
      tag: '${{CF_SHORT_REVISION}}'
      dockerfile: Dockerfile
  PushToCodeFresh:
      type: push
      stage: "push"
      title: Push to Remote Repository
      candidate: ${{BuildImage}}
      tag: '${{CF_SHORT_REVISION}}'
      image_name: medium-customer
      registry: cfcr
      fail_fast: false

We’re telling the build pipeline to clone our repo, use maven to build the jar and then execute docker build (like we did in the last section) to package the jar into an image. We then push that image to codefresh’s docker image registry.

Go ahead and run it and make sure that it builds an image correctly. We can view the docker image registry via the browser to confirm the build.

Hooking it into Our Master Commit

We should have a trigger already set. Click on triggers on the right bar and confirm that a trigger for github exists. You can view it with the pencil. It should be listening for push commits. We can test that by making a commit to any of our branches.

0 comments on “Automated Build PipelineAdd yours →

Leave a Reply

Your email address will not be published.