-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker_build.sh
More file actions
30 lines (22 loc) · 852 Bytes
/
docker_build.sh
File metadata and controls
30 lines (22 loc) · 852 Bytes
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
#!/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"
# 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; }