-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker_run.sh
33 lines (25 loc) · 1 KB
/
docker_run.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/bash
# Exit immediately if a command exits with a non-zero status
set -e
set -o pipefail
if ! command -v docker &> /dev/null; then
echo "Docker is not installed. Exiting..."
exit 1
fi
# Define the image name
IMAGE_NAME=${1:-"langgraph-server:latest"}
VERSION="1.0.0"
FULL_IMAGE_NAME="$IMAGE_NAME:$VERSION"
CONTAINER_NAME=${2:-"langgraph_container"}
# Uncomment if needed
# docker rmi $IMAGE_NAME
# docker builder prune --all --force
# Remove all containers based on the specified image, both stopped and exited
echo "Removing containers based on $FULL_IMAGE_NAME..."
docker ps -a -q --filter "ancestor=$FULL_IMAGE_NAME" | xargs -r docker rm -f
# Build the new image with the specified tag
# Example for error handling after docker build
echo "Building new image $FULL_IMAGE_NAME..."
docker build --no-cache -t $FULL_IMAGE_NAME . || { echo "Docker build failed"; exit 1; }
# Run the newly built container with the name and expose port 8000
docker run -d --name $CONTAINER_NAME -p 8000:8000 $FULL_IMAGE_NAME