Customer microservices demo, usinged by Nudemo mobile app.
403
This project deals with a customer microservice created from the leiningen 'compojure' template.
Usinged by Nudemo mobile app.
You will need Leiningen 2.9.1 or above installed.
Libraries:
Plugins:
To start a web server for the application, run:
lein ring server-headless
Default ring port changed from
3000to 9000
To test the project, run:
lein midje
To test the project in development stage, run:
lein midje :autotest
Automatically reloading the test with each change
To test only Unit tests of the project, run:
lein midje :filter unit
To test only Assertion tests of the project, run:
lein midje :filter assertion
To check test coverage, run:
lein cloverage --runner :midje
To perform a quick End-to-End test on this service (with cURL)
Check health
curl http://localhost:9000/
Get customers list
curl http://localhost:9000/customer/
Get customer info (customer details)
curl http://localhost:9000/customer/:customer-id/
The :customer-id is an [UUID][] automatically generated by the service after registration
Create a customer
curl -X POST \
-d '{"name": "Chinnon Santos", "e-mail": "[email protected]", "phone": "62998639999"}' \
-H "Content-Type: application/json" \
localhost:9000/customer/
Hitting an invalid route
curl http://localhost:9000/invalid/
To perform a complete automated End-to-End test on this service I recommend use the Postman
To create standalone artifact (.jar)
lein ring uberjar
To run standalone artifact (need Java JRE)
java -jar target/customer-1.0.2.jar
See all releases of this project here!
This project is available in a containerized form on the Docker hub repository.
To running the container with Docker commands
sudo docker network create nudemo-services
sudo docker run -d --rm --name customer --net nudemo-services -p 9000:9000 chinnonsantos/customer-service:1.0.2
To go up the service manually with Docker commands
# Ubuntu eoan -> 19.10
sudo docker pull ubuntu:eoan
sudo docker network create nudemo-services
sudo docker run -it --rm --name customer --net nudemo-services -p 9000:9000 ubuntu:eoan
## Inside the container... (sudo docker attach customer-service)
# Updating Ubuntu APT packages
apt update
# Installing Wget package
apt install wget -y
# Installing OpenJDK 11
apt install openjdk-11-jre-headless -y && java --version
# Installing Leiningen
cd /usr/local/bin && wget https://raw.githubusercontent.com/technomancy/leiningen/stable/bin/lein && ls
chmod +x lein && ls && ./lein && lein -v
# Creating app directory
mkdir /home/customer-service
## Outside the container... (Ctrl+P and Ctrl+Q)
# Copying project files to container ('~/Projects/' change to 'YOUR_PROJECT_FOLDER')
sudo docker cp ~/Projects/customer-service/src customer-service:/home/customer-service/src
sudo docker cp ~/Projects/customer-service/project.clj customer-service:/home/customer-service
## Inside the container... (sudo docker attach customer-service)
# Downloading Leiningen project dependencies
cd /home/customer-service
lein deps
# Create standalone artifact (.jar)
lein ring uberjar
# Uninstalling packages and cleaning the system for reduce container size
apt remove wget -y && apt autoremove -y && apt autoclean -y && apt clean -y
cp target/customer-1.0.2.jar .
rm -rf /var/lib/apt/lists/ /tmp/ /var/tmp/ /root/.lein/ /root/.m2/ /root/.wget-hsts /usr/local/bin/lein /home/customer-service/project.clj /home/customer-service/src/ /home/customer-service/target/ /home/customer-service/test/
# Starting service (run standalone artifact)
java -jar customer-1.0.2.jar
To go up the service automatically with Dockerfile
sudo docker build -t chinnonsantos/customer-service:1.0.2 --no-cache .
sudo docker network create nudemo-services
sudo docker run -d --rm --name customer --net nudemo-services -p 9000:9000 chinnonsantos/customer-service:1.0.2
See all images of this project here!
Copyright © 2019 ~ 2020 | Chinnon Santos | Apache License 2.0
Content type
Image
Digest
Size
159 MB
Last updated
over 6 years ago
docker pull chinnonsantos/customer-service