Skip to content

Commit

Permalink
Update deploy.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
alrz1999 committed Aug 25, 2023
1 parent ff65670 commit bbf59a5
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,27 @@

# Build images
echo "Building UserManagementService image..."
docker build -t user-management-service ./UserManagementService
docker build -t user-management-service:latest ./UserManagementService

echo "Building NoteService image..."
docker build -t note-service ./NoteService
docker build -t note-service:latest ./NoteService

echo "Building db image..."
docker build -t note-db ./db
docker build -t note-db:latest ./db

# Deploy Docker Swarm stack
STACK_NAME="my-stack"
COMPOSE_FILE="docker-compose.swarm.yml"

# Check if the stack exists and deploy/update accordingly
if docker stack ls | grep -q "$STACK_NAME"; then
echo "Removing existing services..."
docker service rm ${STACK_NAME}_user-management-service
docker service rm ${STACK_NAME}_note-service

echo "Updating existing stack: $STACK_NAME"
docker stack deploy -c $COMPOSE_FILE $STACK_NAME
docker stack deploy --resolve-image=always -c $COMPOSE_FILE $STACK_NAME
else
echo "Creating new stack: $STACK_NAME"
docker stack deploy -c $COMPOSE_FILE $STACK_NAME
docker stack deploy --resolve-image=always -c $COMPOSE_FILE $STACK_NAME
fi

0 comments on commit bbf59a5

Please sign in to comment.