DevOps Classroom notes 06/Nov/2024

Deploy a Spring boot application

  • Spring boot application can be deployed in two ways
    • as an application
    • as a service
  • Download Jar file Refer Here
  • As an applicaton
    • Install openjdk 17 sudo apt install openjdk-17-jdk
    • run the application java -jar spring-petclinic-3.3.0-SNAPSHOT.jar
    • This application will be hosted on port 8080
  • As a service:
    • Refer Here for an article to run spring boot as a service
    • Lets create a user spc with homedirectory as /var/lib/spc => sudo useradd -d '/var/lib/spc' -m -s '/bin/sh' spc
    • Download the jar file into /var/lib/spc => sudo wget -P /var/lib/spc/ https://referenceappslt.s3.ap-south-1.amazonaws.com/spring-petclinic-3.3.0-SNAPSHOT.jar
    • change ownership sudo chown spc:spc spring-petclinic-3.3.0-SNAPSHOT.jar
    • Now create a service file in the following location /usr/lib/systemd/system/spc.service
      “`
      [Unit]
      Description=A Spring Boot application
      After=syslog.target

    [Service]
    User=spc
    ExecStart=/usr/bin/java -jar /var/lib/spc/spring-petclinic-3.3.0-SNAPSHOT.jar SuccessExitStatus=143

    [Install]
    WantedBy=multi-user.target
    ``
    * Relaod the daemon
    sudo systemctl daemon-reload`
    * Enable and start the spc service

Ansible Playbook for deploying spring petclinic

  • Ubuntu: Initially lets focus on running this playbook on ubuntu
  • Refer Here for the playbook written in the class to automate the deployment of spring petclinic
Published
Categorized as Uncategorized Tagged

By continuous learner

devops & cloud enthusiastic learner

Leave a comment

Turn on JavaScript to leave a comment.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Please turn AdBlock off
Social Media Icons Powered by Acurax Web Design Company
Exit mobile version
%%footer%%