Add release scripts to repsitory

This commit is contained in:
Vikas Nale 2025-05-19 11:12:24 +05:30
commit 19ad3e0426
10 changed files with 396 additions and 0 deletions

9
prod/config.env Normal file
View File

@ -0,0 +1,9 @@
# config.env
ENVIRONMENT=production
WEB_BRANCH_NAME=Issue_May_2W
WEB_IMAGE_NAME=marco.web.prod:v1.1
WEB_CONTAINER_NAME=marco.web.prod
API_BRANCH_NAME=Issues_May_2W
API_IMAGE_NAME=marco.api.prod:v1.1
API_CONTAINER_NAME=marco.api.prod
API_URL=https://api.marcoaiot.com

52
prod/publish-api.sh Normal file
View File

@ -0,0 +1,52 @@
# #!/bin/bash
# Load config file
source ./config.env
# Step 1: set branch Name
IMAGE_NAME=$API_IMAGE_NAME
CONTAINER_NAME=$API_CONTAINER_NAME
REPO_DIR="marco.pms.api"
# Navigate into the project directory
if [ -d "$REPO_DIR" ]; then
cd "$REPO_DIR" || exit
echo "Changed directory to $REPO_DIR"
else
echo "Folder '$REPO_DIR' does not exist. Exiting..."
exit 1
fi
# Step 2: Build the Docker image
echo "Building the Docker image..."
# docker build -t $IMAGE_NAME -f Marco.Pms.Services/Dockerfile .
echo "?? Building Docker image: $IMAGE_NAME"
if ! docker build -t "$IMAGE_NAME" -f Marco.Pms.Services/Dockerfile .; then
echo "? Docker build failed for image: $IMAGE_NAME"
exit 1
fi
echo "Image Name:$IMAGE_NAME"
echo "Container Name: $CONTAINER_NAME"
# Step 3: Stop and remove any existing container with the same name
if sudo docker ps -q --filter "name=$CONTAINER_NAME"; then
echo "Stopping and removing existing container..."
sudo docker stop "$CONTAINER_NAME"
sudo docker rm "$CONTAINER_NAME"
fi
# Step 5: Run the Docker containerer
echo "Running Docker container..."
docker run -d --name $CONTAINER_NAME --network mynetwork -p 8085:8080 -p 8086:8081 $IMAGE_NAME
# Step 6: Final Message
echo "Successfully Running $CONTAINER_NAME"

76
prod/publish-client.sh Normal file
View File

@ -0,0 +1,76 @@
#!/bin/bash
# Load config file
source ./config.env
# Set the name for the Docker image and container
IMAGE_NAME=$WEB_IMAGE_NAME
CONTAINER_NAME=$WEB_CONTAINER_NAME
REPO_DIR="marco.pms.web"
VITE_API_URL=$API_URL
# Navigate into the cloned project directory
if [ -d "$REPO_DIR" ]; then
cd "$REPO_DIR" || exit
echo "------------ Changed directory to $REPO_DIR"
else
echo "------------ Folder '$REPO_DIR' does not exist. Exiting..."
exit 1
fi
#cd marco.pms.web || exit
# Step 2: Install dependencies
echo "------------ Installing dependencies using npm..."
npm install
# Step 3: Build the Client app
echo "------------ Building the React app..."
npm run build
# Step 4: Delete Existing Container
if sudo docker ps -q --filter "name=$CONTAINER_NAME"; then
echo "------------ Stopping existing container..."
sudo docker stop "$CONTAINER_NAME"
sudo docker rm "$CONTAINER_NAME"
else
echo "------------ No existing container found for: $CONTAINER_NAME"
fi
# Step 5: Delete Existing Image
# Check if the image exists
if docker images | awk '{print $1}' | grep -q "^$IMAGE_NAME"; then
echo "------------ Deleting existing Docker image: $IMAGE_NAMEE"
docker rmi -f $IMAGE_NAME
else
echo "------------ No existing image found for: $IMAGE_NAME"
fi
echo "------------ Image Name:$IMAGE_NAME"
echo "------------ Container Name: $CONTAINER_NAME"
echo "------------ Image Name: $IMAGE_NAME"
echo "------------ VITE_API_URL:$VITE_API_URL"
# Step 6: Build New Client Image
echo "------------ Building Docker image..."
sudo docker build -t "$IMAGE_NAME" .
# Go to outer directory
cd ../
# Step 7: Run the Docker containerer
echo "------------ Running Docker container..."
docker run -d --name "$CONTAINER_NAME" -p 4175:4173 \
-e VITE_API_URL="$VITE_API_URL" "$IMAGE_NAME"
# Final message
echo "------------ Successfully Running $CONTAINER_NAME"

30
prod/pull-api.sh Normal file
View File

@ -0,0 +1,30 @@
#!/bin/bash
# Load config file
source ./config.env
#set branch Name
BRANCH_NAME=$API_BRANCH_NAME
# Repository URL
REPO_URL="https://git.marcoaiot.com/admin/marco.pms.api.git"
REPO_DIR="marco.pms.api"
# Step 1: Clone the GitHub repository (use the branch defined)
if [ -d "$REPO_DIR" ]; then
echo "Repository already exists. Pulling latest changes from branch $BRANCH_NAME..."
cd "$REPO_DIR" || exist 1
# ensure we are on correct branch
git fetch origin
git checkout "$BRANCH_NAME"
git pull origin "$BRANCH_NAME"
else
echo "Cloning the Git repository from branch $BRANCH_NAME..."
git clone -b "$BRANCH_NAME" "$REPO_URL"
cd "$REPO_DIR" || exit 1
fi
echo "Successfully pull $BRANCH_NAME"

31
prod/pull-client.sh Normal file
View File

@ -0,0 +1,31 @@
#!/bin/bash
# Load config file
source ./config.env
#set branch Name
BRANCH_NAME=$WEB_BRANCH_NAME
# Repository URL
REPO_URL="https://git.marcoaiot.com/admin/marco.pms.web.git"
REPO_DIR="marco.pms.web"
# Step 1: Clone the GitHub repository (use the branch defined)
if [ -d "$REPO_DIR" ]; then
echo "Repository already exists. Pulling latest changes from branch $BRANCH_NAME..."
cd "$REPO_DIR" || exist 1
# ensure we are on correct branch
git fetch origin
git checkout "$BRANCH_NAME"
git pull origin "$BRANCH_NAME"
else
echo "Cloning the Git repository from branch $BRANCH_NAME..."
git clone -b "$BRANCH_NAME" "$REPO_URL"
cd "$REPO_DIR" || exit 1
fi
echo "Successfully pull $BRANCH_NAME"

9
stage/config.env Normal file
View File

@ -0,0 +1,9 @@
# config.env
ENVIRONMENT=staging
WEB_BRANCH_NAME=Issue_May_2W
WEB_IMAGE_NAME=marco.web
WEB_CONTAINER_NAME=marco.web
API_BRANCH_NAME=Issues_May_2W
API_IMAGE_NAME=marco.api
API_CONTAINER_NAME=marco.api
API_URL=https://stageapi.marcoaiot.com

52
stage/publish-api.sh Normal file
View File

@ -0,0 +1,52 @@
# #!/bin/bash
# Load config file
source ./config.env
# Step 1: set branch Name
IMAGE_NAME=$API_IMAGE_NAME
CONTAINER_NAME=$API_CONTAINER_NAME
REPO_DIR="marco.pms.api"
# Navigate into the project directory
if [ -d "$REPO_DIR" ]; then
cd "$REPO_DIR" || exit
echo "Changed directory to $REPO_DIR"
else
echo "Folder '$REPO_DIR' does not exist. Exiting..."
exit 1
fi
# Step 2: Build the Docker image
echo "Building the Docker image..."
# docker build -t $IMAGE_NAME -f Marco.Pms.Services/Dockerfile .
echo "?? Building Docker image: $IMAGE_NAME"
if ! docker build -t "$IMAGE_NAME" -f Marco.Pms.Services/Dockerfile .; then
echo "? Docker build failed for image: $IMAGE_NAME"
exit 1
fi
echo "Image Name:$IMAGE_NAME"
echo "Container Name: $CONTAINER_NAME"
# Step 3: Stop and remove any existing container with the same name
if sudo docker ps -q --filter "name=$CONTAINER_NAME"; then
echo "Stopping and removing existing container..."
sudo docker stop "$CONTAINER_NAME"
sudo docker rm "$CONTAINER_NAME"
fi
# Step 5: Run the Docker containerer
echo "Running Docker container..."
docker run -d --name $CONTAINER_NAME --network mynetwork -p 8080:8080 -p 8081:8081 $IMAGE_NAME
# Step 6: Final Message
echo "Successfully Running $CONTAINER_NAME"

76
stage/publish-client.sh Normal file
View File

@ -0,0 +1,76 @@
#!/bin/bash
# Load config file
source ./config.env
# Set the name for the Docker image and container
IMAGE_NAME=$WEB_IMAGE_NAME
CONTAINER_NAME=$WEB_CONTAINER_NAME
REPO_DIR="marco.pms.web"
VITE_API_URL=$API_URL
# Navigate into the cloned project directory
if [ -d "$REPO_DIR" ]; then
cd "$REPO_DIR" || exit
echo "------------ Changed directory to $REPO_DIR"
else
echo "------------ Folder '$REPO_DIR' does not exist. Exiting..."
exit 1
fi
#cd marco.pms.web || exit
# Step 2: Install dependencies
echo "------------ Installing dependencies using npm..."
npm install
# Step 3: Build the Client app
echo "------------ Building the React app..."
npm run build
# Step 4: Delete Existing Container
if sudo docker ps -q --filter "name=$CONTAINER_NAME"; then
echo "------------ Stopping existing container..."
sudo docker stop "$CONTAINER_NAME"
sudo docker rm "$CONTAINER_NAME"
else
echo "------------ No existing container found for: $CONTAINER_NAME"
fi
# Step 5: Delete Existing Image
# Check if the image exists
if docker images | awk '{print $1}' | grep -q "^$IMAGE_NAME"; then
echo "------------ Deleting existing Docker image: $IMAGE_NAMEE"
docker rmi -f $IMAGE_NAME
else
echo "------------ No existing image found for: $IMAGE_NAME"
fi
echo "------------ Image Name:$IMAGE_NAME"
echo "------------ Container Name: $CONTAINER_NAME"
echo "------------ Image Name: $IMAGE_NAME"
echo "------------ VITE_API_URL:$VITE_API_URL"
# Step 6: Build New Client Image
echo "------------ Building Docker image..."
sudo docker build -t "$IMAGE_NAME" .
# Go to outer directory
cd ../
# Step 7: Run the Docker containerer
echo "------------ Running Docker container..."
docker run -d --name "$CONTAINER_NAME" -p 4173:4173 \
-e VITE_API_URL="$VITE_API_URL" "$IMAGE_NAME"
# Final message
echo "------------ Successfully Running $CONTAINER_NAME"

30
stage/pull-api.sh Normal file
View File

@ -0,0 +1,30 @@
#!/bin/bash
# Load config file
source ./config.env
#set branch Name
BRANCH_NAME=$API_BRANCH_NAME
# Repository URL
REPO_URL="https://git.marcoaiot.com/admin/marco.pms.api.git"
REPO_DIR="marco.pms.api"
# Step 1: Clone the GitHub repository (use the branch defined)
if [ -d "$REPO_DIR" ]; then
echo "Repository already exists. Pulling latest changes from branch $BRANCH_NAME..."
cd "$REPO_DIR" || exist 1
# ensure we are on correct branch
git fetch origin
git checkout "$BRANCH_NAME"
git pull origin "$BRANCH_NAME"
else
echo "Cloning the Git repository from branch $BRANCH_NAME..."
git clone -b "$BRANCH_NAME" "$REPO_URL"
cd "$REPO_DIR" || exit 1
fi
echo "Successfully pull $BRANCH_NAME"

31
stage/pull-client.sh Normal file
View File

@ -0,0 +1,31 @@
#!/bin/bash
# Load config file
source ./config.env
#set branch Name
BRANCH_NAME=$WEB_BRANCH_NAME
# Repository URL
REPO_URL="https://git.marcoaiot.com/admin/marco.pms.web.git"
REPO_DIR="marco.pms.web"
# Step 1: Clone the GitHub repository (use the branch defined)
if [ -d "$REPO_DIR" ]; then
echo "Repository already exists. Pulling latest changes from branch $BRANCH_NAME..."
cd "$REPO_DIR" || exist 1
# ensure we are on correct branch
git fetch origin
git checkout "$BRANCH_NAME"
git pull origin "$BRANCH_NAME"
else
echo "Cloning the Git repository from branch $BRANCH_NAME..."
git clone -b "$BRANCH_NAME" "$REPO_URL"
cd "$REPO_DIR" || exit 1
fi
echo "Successfully pull $BRANCH_NAME"