GithubHelp home page GithubHelp logo

reddi72 / java-maven-calculator-web-app Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ravdy/java-maven-calculator-web-app

0.0 0.0 0.0 197 KB

A Java calculator web app, build by Maven, CI/CD by Jenkins.

Java 94.93% HTML 2.95% Dockerfile 2.12%

java-maven-calculator-web-app's Introduction

A Java Maven Calculator Web App

A Java calculator web app, build by Maven, CI/CD by Jenkins.

image

image from https://jenkins.io/doc/book/pipeline/

1. Manualy Build, Test, and Deploy By Maven

1.1 Build

mvn clean package

1.2 Run Locally

mvn jetty:run

By default, the jetty port is 9999, so you should visit following urls in browser:

http://localhost:9999/calculator/api/calculator/ping

http://localhost:9999/calculator/api/calculator/add?x=8&y=26

http://localhost:9999/calculator/api/calculator/sub?x=12&y=8

http://localhost:9999/calculator/api/calculator/mul?x=11&y=8

http://localhost:9999/calculator/api/calculator/div?x=12&y=12

To run in a different port

mvn jetty:run -Djetty.port=<your port>

1.3 Debug Locally

set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=8000,suspend=n
mvn jetty:run

1.4 Run JUnit Test

mvn clean test

1.5 Run Integration Test

mvn clean integration-test

1.6 Deploy Your Web App to An Existed Tomcat 8x

You need change pom.xml, point to your Tomcat 8x.

mvn cargo:run

1.7 Run Performance Test with JMeter

You need install Jmeter first, and make sure your Tomcat 8x is runing.

mvn clean verify

To run in command line mode with parameters

./bin/jmeter.sh -n -t ./tests/CalculatorTestPlan.jmx -Jusers=20 -Jloop=2 -l ./results/calculator_`date +'%y%m%d%H%M%S'`.cs

1.8 Build Project Site

mvn site

2. Automaticly Build, Test, and Deploy By Jenkins

2.1 Create and Configure a Freestyle Jenkins Project

Project name: MyJavaMavenCalculateWebApp

Execute every mvn goal one by one defined in Build Section Step: "Invoke top-level Maven targets"

2.2 Create and Configure a Freestyle Jenkins Project, using Publish Over FTP plugin

Project name: MyJavaMavenCalculateWebApp-AzureAppService-FTP

2.3 Create and Configure a Freestyle Jenkins Project, using Azure App Service plugin

Project name: MyJavaMavenCalculateWebApp-AzureAppService

2.4 Create and Configure a Pipeline Jenkins Project

Project name: MyJavaMavenCalculateWebApp-Pipeline

Execute the Jenkins Pipeline Script File: Jenkinsfile

3. Containerize Your Web App

  1. Build a docker image using Dockerfile:

    docker build -t calculator .
    
  2. Run docker image locally

    docker run --rm -p 8080:8080 calculator
    
  3. Then you can access the web app at http://localhost:8080/api/calculator/ping in browser

  4. Stop container

    docker ps -a
    docker stop <Container-ID>
    
  5. Push your local image to your docker hub repositories

    docker login -u <Your-Docker-ID> -p <Your-Docker-Password>
    docker tag calculator <Your-Docker-ID>/calculator
    docker push <Your-Docker-ID>/calculator
    

4. Deploy to Azure Web App using Container Image in Docker Hub

  1. Create a Web App in Linux on Azure
  2. Save the changes and you'll be able to access the web app in a few seconds.

5. Deploy to Your Azure Web App using Container Image in ACR

  1. Create a Container Registry on Azure
  2. Push your local image to ACR:
    docker login <Your-ACR-Login-Server> -u <Your-ACR-Username> -p <Your-ACR-Password>
    docker tag calculator <Your-ACR-Login-Server>/calculator
    docker push <Your-ACR-Login-Server>/calculator
    
  3. Create a Web App in Linux on Azure
  4. In Docker Container settings of Web App, fill in image name, server URL, username and password of your ACR.
  5. Save the changes and you'll be able to access the web app in a few seconds.

java-maven-calculator-web-app's People

Contributors

maping avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.