From 5f507e9566371512b1ee6e8b0ee7c474a0daaed9 Mon Sep 17 00:00:00 2001 From: Ledjon Behluli Date: Thu, 26 Nov 2020 10:09:28 +0100 Subject: [PATCH] - Modified "git-clone.sh" so it can clone the other repos without replacing the actual file location. - Modified "git-pull.sh" so it can pull all branches and updated the repos without replacing the actual file location. - Added "git-pull-run-local.sh" which: - Pulls latest changes for each repo. - Stops all running containers. - Creates the pacco-network (if not already created). - Rebuilds local containers and runs them (This fixes also the container orphan issue). --- scripts/git-clone.sh | 3 ++- scripts/git-pull-run-local.sh | 34 ++++++++++++++++++++++++++++++++++ scripts/git-pull.sh | 4 +++- 3 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 scripts/git-pull-run-local.sh diff --git a/scripts/git-clone.sh b/scripts/git-clone.sh index 89ab826..ab41ce5 100755 --- a/scripts/git-clone.sh +++ b/scripts/git-clone.sh @@ -7,6 +7,7 @@ do echo Cloning the repository: $REPOSITORY echo ======================================================== REPO_URL=https://github.com/devmentors/$REPOSITORY.git + cd ../../ git clone $REPO_URL - cd $REPOSITORY && cd .. + cd - done \ No newline at end of file diff --git a/scripts/git-pull-run-local.sh b/scripts/git-pull-run-local.sh new file mode 100644 index 0000000..48968d7 --- /dev/null +++ b/scripts/git-pull-run-local.sh @@ -0,0 +1,34 @@ +#!/bin/bash +REPOSITORIES=(Pacco.APIGateway Pacco.APIGateway.Ocelot Pacco.Services.Availability Pacco.Services.Customers Pacco.Services.Deliveries Pacco.Services.Identity Pacco.Services.Operations Pacco.Services.Orders Pacco.Services.OrderMaker Pacco.Services.Parcels Pacco.Services.Pricing Pacco.Services.Vehicles) + + for REPOSITORY in ${REPOSITORIES[*]} + do + echo ======================================================== + echo Updating the repository: $REPOSITORY + echo ======================================================== + cd ../../$REPOSITORY + git checkout develop && git pull && git checkout master && git pull + cd - + done + + echo ======================================================== + echo "stoping all containers..." + echo ======================================================== + + container_ids=($(docker ps -a -q)) + echo container_ids + for container_id in ${container_ids[@]} + do + echo stopping container with Id: ${container_id} + eval docker stop ${container_id} + echo stopped + echo ======================================================== + done + +echo ======================================================== +echo "building & starting all services..." +echo ======================================================== +cd ../compose +eval "docker network create pacco-network || true" +eval "docker-compose -f services-local.yml up --build --remove-orphans" +echo "DONE" \ No newline at end of file diff --git a/scripts/git-pull.sh b/scripts/git-pull.sh index c07afb7..741f5d3 100755 --- a/scripts/git-pull.sh +++ b/scripts/git-pull.sh @@ -6,5 +6,7 @@ do echo ======================================================== echo Updating the repository: $REPOSITORY echo ======================================================== - cd $REPOSITORY && git checkout develop && git pull && git checkout master && git pull && cd .. + cd ../../$REPOSITORY + git checkout develop && git pull && git checkout master && git pull + cd - done \ No newline at end of file