You should create a folder in a directory and put config files there (under the appConfigs
directory in this repo).
Run ./mvnw clean package
in the project folder; after a while, Maven prints out the project's jar
file path on the terminal.
After maven build, the Jar file usually is in target/finalProject-0.1-spring-boot.jar
, and you can run the application by the following command:
java -jar target/finalProject-0.1-spring-boot.jar --spring.config.name=applicationConfig,secretConfig --spring.config.location=file:///home/ali/appConfigs/
Note that applicationConfig.properties
and secretConfig.properties
are config files name under the directory of /home/ali/appConfigs/
that I had created before.
Note that there is no need to change user value inside applicationConfig.properties
if you are making database using below commands
First creat volume with docker volume create myDBVolume
Then build docker compose file with sudo docker-compose build
Finaly run the system with sudo docker-compose up
Note that domain address in ./appConfigs/applicationConfig.properties
should be mysql
Simply run
sudo docker run --detach --name={containerName} --env="MYSQL_ROOT_PASSWORD={rootPassword}" --publish {host port}:{DBport} --volume=/root/docker/{containerName}/conf.d:/etc/mysql/conf.d --volume={DBlocalStorage}:/var/lib/mysql mysql
Before doing the following steps, see ip address of database wiith sudo docker inspect {container name}
and replace domain address in ./appConfigs/applicationConfig.properties
with founded ip.
For creating docker runtime image of project run sudo docker build -t {your desired name of image} .
Then run the image using
sudo docker run --mount type=bind,src={HostPathToConfigFolder},target=/usr/src/conf -p {HostPort}:8081 -it {yourDesiredNameOfImage}
check out https://minikube.sigs.k8s.io/docs/start/
for x86-64 architucture follow these steps:
- curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
- sudo install minikube-linux-amd64 /usr/local/bin/minikube
- minikube start
Note that if part 3 didnt go well, try to contact me :)
try following steps in order and you will be fine!
first go to the ./kuber
path then:
-
minikube kubectl apply -f secret.yaml
orsudo minikube kubectl -- apply -f secret.yaml
-
minikube kubectl apply -f config-map.yaml
orsudo minikube kubectl -- apply -f config-map.yaml
-
minikube kubectl apply -f config-map2.yaml
orsudo minikube kubectl -- apply -f config-map2.yaml
-
minikube kubectl apply -f mysql-storage.yaml
orsudo minikube kubectl -- apply -f mysql-storage.yaml
-
minikube kubectl apply -f mysql-deployment.yaml
orsudo minikube kubectl -- apply -f mysql-deployment.yaml
after this step check the STATUS of pods bysudo minikube kubectl get pod -- -o wide
command, it should be RUNNING after a while. -
minikube kubectl apply -f mysql-service.yaml
orsudo minikube kubectl -- apply -f mysql-service.yaml
now database setup is completed. Usesudo minikube kubectl get deployment -- -o wide
andsudo minikube kubectl get service -- -o wide
for checking status.
-
minikube kubectl apply -f secret.yaml
orsudo minikube kubectl -- apply -f secret.yaml
-
minikube kubectl apply -f config-map.yaml
orsudo minikube kubectl -- apply -f config-map.yaml
-
minikube kubectl apply -f config-map2.yaml
orsudo minikube kubectl -- apply -f config-map2.yaml
-
minikube kubectl apply -f urlshortener-deployment.yaml
orsudo minikube kubectl -- apply -f urlshortener-deployment.yaml
after this step check the STATUS of pods bysudo minikube kubectl get pod -- -o wide
command, it should be RUNNING after a while. -
minikube kubectl apply -f urlshortener-service.yaml
orsudo minikube kubectl -- apply -f urlshortener-service.yaml
now database setup is completed. Usesudo minikube kubectl get deployment -- -o wide
andsudo minikube kubectl get service -- -o wide
for checking status.
If you reach here, It is all done. For testing your service try steps below:
Before moving forward save try to copy the ip of the service in the sudo minikube kubectl get service -- -o wide
command.
Method1:
sudo minikube kubectl run test -- --image=danialkm/myubuntu:latest sleep infinity
sudo minikube kubectl exec -- --stdin --tty test -- bash
in the opened bash check the system working by typing Usage command below!
Note that instead oflocalhost
in the POST url, you need to type service ip.
Method2:
simply use sudo minikube kubectl port-forward service/urlshortener 8081:8081
and then you can use system with Usage command that is described below.
curl --location --request POST 'http://localhost:8081/doit' --header 'Content-Type: application/json' --data '{"url":"https://01d.ir/test"}'
you can go to the desired link by opening http://localhost:8081/{code}
Enjoy!