PartsUnlimitedMRPmicro/OrderSrvc
David Tesar 5fd475314c
Update helm charts, Readme bash scripts (#22)
- Refactor the helm charts to only have one shared chart, updating this chart to be resilient to handle all APIs
- Update the deploy readme to be accurate and more condensed
- Fix the APIs to actually use the mongo_conn and expose_port ENV variables
- Add .dockerignore file to speed up local docker builds where node_modules is present from the mongodb npm package
- Fix the web client to have the proper internal API addresses for the k8s cluster
2018-12-06 14:32:29 -08:00
..
gradle/wrapper initial commit 2017-04-21 22:47:49 -07:00
lib initial commit 2017-04-21 22:47:49 -07:00
resources initial commit 2017-04-21 22:47:49 -07:00
src Update helm charts, Readme bash scripts (#22) 2018-12-06 14:32:29 -08:00
.gitignore initial commit 2017-04-21 22:47:49 -07:00
Dockerfile update image labels 2017-11-06 10:39:40 -08:00
README.md Update dockerfiles, add readmes, fix CI (#8) 2017-07-18 15:52:18 -07:00
azure-pipelines.yml Adding Azure Pipelines CI builds (#26) 2018-12-06 14:15:51 -08:00
build.gradle initial commit 2017-04-21 22:47:49 -07:00
gradlew initial commit 2017-04-21 22:47:49 -07:00
gradlew.bat initial commit 2017-04-21 22:47:49 -07:00
removeBuild.bat Update dockerfiles, add readmes, fix CI (#8) 2017-07-18 15:52:18 -07:00

README.md

Order Microservice

The order microservice is an API created using java spring connecting to MongoDB or CosmosDB and provides a order of inventory for the fictional outsourced Manufacturing Resource Planning (MRP) application. The build process creates a single archive (jar) file that is used by the Tomcat host for the service.

This microservice is also available as a docker image on Docker hub.

Below, learn how to:

Build the service
Run the service
Clean all builds
See Unit Tests

Build the Order Service

Below are instructions on how to build the order service using Windows, Linux, or Docker.

  1. Windows

    Building on Windows the following command is used to build the order JAR file.

    .\gradlew.bat build
    
  2. Linux

    Building on Linux the following command is used to build the order JAR file.

        # ensure the 'gradlew' is executable
        chmod +x gradlew
    
        # now build
        ./gradlew build
    
  3. Docker
    This describes how to build the image using a publicly available docker image which has gradle installed.

    From the root of the repository, execute:

    docker run --rm -v $PWD/OrderSrvc:/project -w /project --name gradle gradle:3.4.1-jdk8-alpine gradle build
    

Any of above steps creates the orderservice-1.0.jar build in the ./build/libs directory.

Run the service

After the build has successfully completed, now it is possible to run the application which creates an available API for the order service. The microservice requires a connection to a MongoDB or CosmosDB (using MongoDB API).

  1. Obtain the connection string to your database.

    A MongoDB or CosmosDB using MongoDB connection string is required for the API to run and must be passed into the image.

    Be sure to insert any database name (lowercase, alphanumeric only) after the base connection url. For instance with CosmosDB string:
    mongodb://mydbserver:longpassword@mydbserver.documents.azure.com:10255/?ssl=true&replicaSet=globaldb
    would add pumrp and now the connection string becomes:
    mongodb://mydbserver:longpassword@mydbserver.documents.azure.com:10255/pumrp?ssl=true&replicaSet=globaldb

  2. Now run the API

    With Java 8 JRE installed locally, execute the following from the ./OrderSrvc directory. Replace the <mongodb-string> in the command below with your own to run the microservice locally on port 8080.

    java -Dspring.data.mongodb.uri=<mongodb-string> -jar -Dserver.port=8080 ./build/libs/*.jar
    

    OR use a java docker image to run the jar via this command:

    docker run -p 8080:8080 -it --rm -v $PWD/OrderSrvc/build/libs:/usr/local/app/ -w /usr/local/app openjdk:8-jre "java -Dspring.data.mongodb.uri=<mongodb-string> -jar -Dserver.port=8080 *.jar"
    

Clean all builds

If you'd like to remove all of the local builds execute the following on Windows or Linux.

  1. Windows

    Run the following from the command prompt:

    removeBuild.bat
    

    to remove the ./build directory.

  2. Linux

    On Linux remove the ./build with the following command to 'clean'

    rm -rf ./build
    

Unit Testing

For unit testing of order service, JUnit test cases are present in /src/test/java/smpl/order/OrderControllerTest.java file. These test cases are executed as a part of build process to verify the basic CRUD operations. Once test cases are executed, you can view test results at ./build/reports/tests/index.html.