5fd475314c
- 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 |
||
---|---|---|
.. | ||
gradle/wrapper | ||
lib | ||
resources | ||
src | ||
.gitignore | ||
Dockerfile | ||
README.md | ||
azure-pipelines.yml | ||
build.gradle | ||
gradlew | ||
gradlew.bat | ||
removeBuild.bat |
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.
-
Windows
Building on Windows the following command is used to build the order JAR file.
.\gradlew.bat build
-
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
-
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).
-
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 addpumrp
and now the connection string becomes:
mongodb://mydbserver:longpassword@mydbserver.documents.azure.com:10255/pumrp?ssl=true&replicaSet=globaldb
-
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.
-
Windows
Run the following from the command prompt:
removeBuild.bat
to remove the
./build
directory. -
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.