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
echo -e "\nSet docker container name as ${CONTAINER_NAME}\n"
IMAGE_NAME=${CONTAINER_NAME}:dev
echo -e "\nSet docker image name as ${IMAGE_NAME}\n"
PORT=8070
echo -e "Set docker image PORT to ${PORT}\n"
# Build de los microservicios con Maven
echo "Building microservices..."
cd ../shoptfront-productcatalogue-stockmanager-Kubernetes
echo -e "Create uber jar...\n"
minikube start
cd shoptfront
mvn clean package
echo -e "\nStop running Docker containers with image tag ${CONTAINER_NAME}, and remove them...n"
docker stop $(docker ps -a | grep ${CONTAINER_NAME} | awk '{print $1}')
docker rm $(docker ps -a | grep ${CONTAINER_NAME} | awk '{print $1}')
cd ..
cd ../productcatalogue
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}