diff --git a/Ekart/scripts/run-app.sh b/Ekart/scripts/run-app.sh index de6ba3d..31b024d 100644 --- a/Ekart/scripts/run-app.sh +++ b/Ekart/scripts/run-app.sh @@ -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} \ No newline at end of file