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,7 +6,12 @@ POSTGRES_VERSION="latest"
MONGODB_VERSION="latest"
# Start PostgreSQL
docker run -d \
if [ "$(docker ps -a -q -f name=^TASKER_POSTGRES$)" ]; then
echo "PostgreSQL container exists. Starting..."
docker start TASKER_POSTGRES
else
echo "PostgreSQL container does not exist. Creating..."
docker run -d \
--name TASKER_POSTGRES \
-v "${DATA_ROOT}/postgres:/var/lib/postgresql/data" \
-p 5400:5432 \
@@ -14,11 +19,18 @@ docker run -d \
-e POSTGRES_PASSWORD=P@ssword123! \
-e POSTGRES_DB=Tasker \
postgres:$POSTGRES_VERSION
fi
# Start MongoDB
docker run -d \
if [ "$(docker ps -a -q -f name=^TASKER_MONGODB$)" ]; then
echo "MongoDB container exists. Starting..."
docker start TASKER_MONGODB
else
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