Continuous deployment of spring boot Apps on Azure App service using GIT lab CI

Continuous deployment of spring boot Apps on Azure App service using GIT lab CI

Continuous deployment is an automated process of releasing production code to the desired infrastructure, Only after Continuous Integration pipelines are satisfied.

CI (Continuous Integration) is making sure every piece of code is tested & validated in an automated fashion whenever code pushed to the shared repository.

The process of CI & CD provides agility in release cycles. And for the hobby projects, I try to incorporate CI and stop my pipeline to continues delivery. Continuous delivery is Act where the production-ready code is waiting to take action manually to deploy with very minimal effort.

For my hobby projects, I usually write micro RESTFUL applications that have a single purpose like Authentication and Authorization, managing the profile of the user's which totally depends on the project's need. This micro Rest app may be reused.  the consumer of these services knows how to consumes the resources.

As I tend to maintain minimum code quality, a major piece of code will be unit tested along with integration tests that will be checked.

I usually don't keep any quality gate criteria, which can be achieved by tools like Sonar Qube.

My CI tool of choice for Spring boot App is GITLab's CI. And my delivery mode for deployment will be in the form of a docker image.

These are the CI pipeline which I follow


Every commit of the code irrespective of any branch is always tested by running Junit test cases.


On every bit of code merged to the master branch. I generate the artifact like Jar or War depending on the project along with the build task.


The feature which needs to be deployed, A versioning tag is generated, this action triggers the package task, which generates the docker image of the application. forming the pipeline of tasks containing build, stage, and package.

  1. Now let us create a `Dockerfile` for the spring app.
FROM maven:3-jdk-11
ADD /target/*.jar app.jar
EXPOSE 8080/tcp
EXPOSE 10250/tcp
ENTRYPOINT ["java","-jar","/app.jar"]

2. Now let's create a pipeline in  `.gitlab-ci.yml` file

image: docker:latest
  - docker:dind

  DOCKER_DRIVER: overlay

  - build
  - stage
  - package

  image: maven:3-jdk-11
  stage: build
    - mvn test
    - mvn verify
    - mvn jacoco:report
        - target/surefire-reports/TEST-*.xml
        - target/failsafe-reports/TEST-*.xml
        - target/site/jacoco/index.html
        - target/site/jacoco/jacoco.xml

  image: maven:3-jdk-11
  stage: stage
  when: on_success
    - tags
  script: "mvn package"
      - target/*.jar

  stage: package
  when: on_success
    - tags
    - docker build -t<repoendpoint> .
    - docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN
    - docker push<repoendpoint>

after these steps push the code to repo and create a tag to generate the docker image.

Now for the first time, we shall create an Azure app space where we need our Docker image need to be deployed by following these steps.

Login to azure portal by using this link :

  1. Create the App service by referring the screen shots

Step 1: Initial Screen.

STEP 1: Initial Screen

Step 2: Creating the resource group, Naming the app, Selecting the docker publish method And Selecting the plan

STEP 2:Creating the resource group, Naming the app, selecting the docker publish method, selecting the plan 

Step 3 : Configuring the docker registry.

Step 3 : Configuring the docker registry.

3. Final configuration

Just stop and start when ever you need to deploy the app service. the latest docker image will be pulled. also you can create CD(continues deployment) by enabling the web hook in GitLab.