From af9e0a46da0bf36f74a8a7443d531dcac92ce6a8 Mon Sep 17 00:00:00 2001 From: Aashwin Mohan Date: Mon, 16 Dec 2024 10:09:02 +0000 Subject: [PATCH] Stop rebuild of base image if not required --- scripts/local-run.sh | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/scripts/local-run.sh b/scripts/local-run.sh index 8412b47..d6e35e9 100755 --- a/scripts/local-run.sh +++ b/scripts/local-run.sh @@ -1,19 +1,26 @@ #!/bin/bash -set -x set -e BASE_DIR=$(dirname "$(realpath "$0")") HOST="local.dev.rvvuptech.com:89" CURRENT_DIR_NAME=$(basename "$PWD") +if [ "$1" = "rebuild" ] || ! docker image inspect magento-hyva-store:latest > /dev/null 2>&1; then + # Ideally, this commit is pushed to docker hub and we don't rebuild everytime, but for now we rebuild temporarily. + docker compose down -v || true + docker image rm $CURRENT_DIR_NAME-magento:latest || true + RVVUP_HYVA_CHECKOUT_VERSION='local' docker compose up -d + $BASE_DIR/helpers/wait-for-server-startup.sh -# Ideally, this commit is pushed to docker hub and we don't rebuild everytime, but for now we rebuild temporarily. -docker compose down -v || true -docker image rm $CURRENT_DIR_NAME-magento:latest || true -RVVUP_HYVA_CHECKOUT_VERSION='local' docker compose up -d -$BASE_DIR/helpers/wait-for-server-startup.sh - -echo "Commiting base image" -docker commit $CURRENT_DIR_NAME-magento-1 magento-hyva-store:latest -echo "Restarting server with volume attached" + echo "Commiting base image" + docker commit $CURRENT_DIR_NAME-magento-1 magento-hyva-store:latest + echo "Restarting server with volume attached" +else + echo -e "\033[33mSkipping rebuild of base magento store image, run with \`./scripts/local-run.sh rebuild\` to rebuild base image.\033[0m" +fi +if docker ps -a --format "{{.Names}}" | grep -q "^$CURRENT_DIR_NAME-magento-1$"; then + echo "Deleting container: $CURRENT_DIR_NAME-magento-1" + docker rm -f "$CURRENT_DIR_NAME-magento-1" + echo "Container $CURRENT_DIR_NAME-magento-1 deleted successfully." +fi RVVUP_HYVA_CHECKOUT_VERSION='local' docker compose -f docker-compose.local.yml up -d $BASE_DIR/helpers/wait-for-server-startup.sh