feat(infra): start-infrastructure.sh either restart containter if they already exists or spawn new one if not

This commit is contained in:
2025-12-19 14:00:57 -05:00
parent 5c93d81ad5
commit 081877096e

View File

@@ -6,19 +6,31 @@ POSTGRES_VERSION="latest"
MONGODB_VERSION="latest" MONGODB_VERSION="latest"
# Start PostgreSQL # Start PostgreSQL
docker run -d \ if [ "$(docker ps -a -q -f name=^TASKER_POSTGRES$)" ]; then
--name TASKER_POSTGRES \ echo "PostgreSQL container exists. Starting..."
-v "${DATA_ROOT}/postgres:/var/lib/postgresql/data" \ docker start TASKER_POSTGRES
-p 5400:5432 \ else
-e POSTGRES_USER=sa \ echo "PostgreSQL container does not exist. Creating..."
-e POSTGRES_PASSWORD=P@ssword123! \ docker run -d \
-e POSTGRES_DB=Tasker \ --name TASKER_POSTGRES \
postgres:$POSTGRES_VERSION -v "${DATA_ROOT}/postgres:/var/lib/postgresql/data" \
-p 5400:5432 \
-e POSTGRES_USER=sa \
-e POSTGRES_PASSWORD=P@ssword123! \
-e POSTGRES_DB=Tasker \
postgres:$POSTGRES_VERSION
fi
# Start MongoDB # Start MongoDB
docker run -d \ if [ "$(docker ps -a -q -f name=^TASKER_MONGODB$)" ]; then
--name TASKER_MONGODB \ echo "MongoDB container exists. Starting..."
-v "${DATA_ROOT}/mongodb:/data/db" \ docker start TASKER_MONGODB
-p 5401:27017 \ else
mongo:$MONGODB_VERSION echo "MongoDB container does not exist. Creating..."
docker run -d \
--name TASKER_MONGODB \
-v "${DATA_ROOT}/mongodb:/data/db" \
-p 5401:27017 \
mongo:$MONGODB_VERSION
fi