Actualizar 'Ekart/scripts/run-app.sh'

This commit is contained in:
Lopera Mendizabal 2024-04-18 15:55:23 +00:00
parent c27e2d9757
commit 5a5d645c9b

View File

@ -1,23 +1,50 @@
#!/usr/bin/env bash #!/bin/bash
CONTAINER_NAME=spring-boot-shopping-cart # Build de los microservicios con Maven
echo -e "\nSet docker container name as ${CONTAINER_NAME}\n" echo "Building microservices..."
IMAGE_NAME=${CONTAINER_NAME}:dev cd ../shoptfront-productcatalogue-stockmanager-Kubernetes
echo -e "\nSet docker image name as ${IMAGE_NAME}\n"
PORT=8070
echo -e "Set docker image PORT to ${PORT}\n"
echo -e "Create uber jar...\n" minikube start
cd shoptfront
mvn clean package mvn clean package
echo -e "\nStop running Docker containers with image tag ${CONTAINER_NAME}, and remove them...n" cd ..
docker stop $(docker ps -a | grep ${CONTAINER_NAME} | awk '{print $1}') cd ../productcatalogue
docker rm $(docker ps -a | grep ${CONTAINER_NAME} | awk '{print $1}') mvn clean package
cd ..
cd ../stockmanager
mvn clean package
cd ..
# Creación de imágenes Docker
echo "Building Docker images..."
cd shoptfront
docker build -t shoptfront:latest .
cd ../productcatalogue
docker build -t productcatalogue:latest .
cd ../stockmanager
docker build -t stockmanager:latest .
cd ..
# Despliegue en Kubernetes
echo "Deploying to Kubernetes..."
kubectl apply -f shoptfront-productcatalogue-stockmanager-kubernetes/kubernetes/shopfront-service.yaml
kubectl apply -f shoptfront-productcatalogue-stockmanager-kubernetes/kubernetes/productcatalogue-service.yaml
kubectl apply -f shoptfront-productcatalogue-stockmanager-kubernetes/kubernetes/stockmanager-service.yaml
# Openning services
minikube service shoptfront-service.yaml
minikube service productcatalogue-service.yaml
minikube service stockmanager-service.yaml
echo -e "\nDocker build image with name ${IMAGE_NAME}...\n"
docker build -t ${IMAGE_NAME} -f docker/Dockerfile .
echo -e "\nStart Docker container of the image ${IMAGE_NAME} with name ${CONTAINER_NAME}...\n"
docker run --rm -i -p ${PORT}:${PORT} \
--name ${CONTAINER_NAME} \
${IMAGE_NAME}