Spring boot application deployed using concourse CI
In this tutorial, We will be learning how to test, build and deploy on Pivotal Cloud Foundry, PCF, your java spring boot application using Concourse CI
Just like any other CI/CD tool, Concourse CI is a DevOps tool to help in automated continuous integration and delivery of your application.
For an effective CI environment to be established, there are THREE thing that need to be put in place
- Version Control Code Repository e.g GitHub, GiLab etc
- An Artifact Repository like Nexus or a File storage S3, Minio to stored build artifacts
- A Deployment environment like Server, EC2 or Cloud Infrastructure Service like PCF environment
However, Some CI/CD tool like Jenkins provides the Artifact Storage implicitly
In this this tutorial, we would be deploying a spring boot application on PCF and we would be using GitHub for Version Control Repository and s3 for artifact storage
Test and Build
This is the first job on our Concourse CI pipeline. It will pull your latest commit form GitHub run all the unit and integration tests, create a .jar artifact and save in S3 storage
This job uses two resources
- git resource : The resource gets the latest commit pushed to git hub
- s3 resource : A bucket to store the output jar file after the test and build process
The git
resource is triggered when a commit-push is made on github. This resource triggers the test-and-build
job to run. which is simply: run all the unit test in the application, build a .jar file and send it to S3 for storage
This job runs a Docker image with java environment set up to be able to build .jar file. The code is pull from github in to the image context, mvn clean package
is run on the pulled git source code to start the tests and create the jar if all the test passes.
When this .jar file is created, use the s3
resource and push the .jar to this specified s3 bucket.
jobs:
- name: test-and-build
public: true
plan:
- get: source-code-from-github
trigger: true
- get: s3-stored-jar
- task: run-test-and-build-jar-file
config:
platform: linux
image_resource:
type: docker-image
source:
repository: java
tag: 8
inputs:
- name: source-code-from-github
outputs:
- name: jar-file
caches:
- path: source-code-from-github/.m2
run:
path: ./source-code-from-github/ci/test-and-build.sh
- put: s3-stored-jar
params:
file: jar-file/*.jar
Deploy application to PCF
During this job the application jar is being deployed to PCF from s3 bucket.
This job triggered after a successful jar is created on S3. The job also uses the git
resource to read the pcf manifest.yml file It also uses the s3
resource to get the deployed jar file. Then finally uses the cf
resource to deploy this jar to PCF
- name: deploy-app-to-pcf
public: true
plan:
- get: s3-stored-jar
passed: [test-and-build]
trigger: true
- get: source-code-from-github
- put: pcf-resource
params:
manifest: source-code-from-github/ci/manifest.yml
All these process start by you doing a simple developer action, git push
Here is the complete pipeline.yml file for the complete process
resources:
- name: source-code-from-github
type: git
source:
uri: https://github.com/eddytnk/deploy-springboot-app-using-concourse-ci
branch: master
- name: s3-stored-jar
type: s3
source:
bucket: eddytnk
region_name: us-east-2
regexp: jars/springboot-concourse-(.*)-SNAPSHOT.jar
access_key_id: ((AWSAccessKeyId))
secret_access_key: ((AWSSecretKey))
- name: pcf-resource
type: cf
source:
api: https://api.run.pivotal.io
username: ((PCF_EMAIL))
password: ((PCF_PASSWORD))
organization: ((PCF_ORG))
space: ((PCF_SPACE))
skip_cert_check: false
jobs:
- name: test-and-build
public: true
plan:
- get: source-code-from-github
trigger: true
- get: s3-stored-jar
- task: run-test-and-build-jar-file
config:
platform: linux
image_resource:
type: docker-image
source:
repository: java
tag: 8
inputs:
- name: source-code-from-github
outputs:
- name: jar-file
caches:
- path: source-code-from-github/.m2
run:
path: ./source-code-from-github/ci/test-and-build.sh
- put: s3-stored-jar
params:
file: jar-file/*.jar
- name: deploy-app-to-pcf
public: true
plan:
- get: s3-stored-jar
passed: [test-and-build]
trigger: true
- get: source-code-from-github
- put: pcf-resource
params:
manifest: source-code-from-github/ci/manifest.yml
Download or Clone source code on GitHub
cols=for other question, When we build container image for spring boot, it will have base images for OS, JDK etc.,If there is security vulnerability reported on base image will PBS automatically build base image+container image for all applications which is using base image and run through pipeline?