diff --git a/.gitignore b/.gitignore index 47d5819..a631434 100644 --- a/.gitignore +++ b/.gitignore @@ -44,4 +44,10 @@ __pycache__/ FILES/* .gitmodules -!FILES/sample.txt \ No newline at end of file +!FILES/sample.txt + +# Ignore .last_build_timestamp because it stores the timestamp of the last Docker build and should not be version controlled. +.last_build_timestamp + +# Ignore doc directory,because it is test doc. +/doc \ No newline at end of file diff --git a/docker.sh b/docker.sh index 6e449ef..7c9c092 100755 --- a/docker.sh +++ b/docker.sh @@ -1,11 +1,28 @@ #!/bin/sh +# Name of the image +IMAGE_NAME="kaguya" + +# File to store the timestamp of the last build +TIMESTAMP_FILE=".last_build_timestamp" + +# Get the modification timestamp of Dockerfile +MOD_TIMESTAMP=$(date -r Dockerfile +%s) + # Get Git user name and email from host machine GIT_NAME=$(git config --get user.name) GIT_EMAIL=$(git config --get user.email) -# Build the Docker image -docker build --build-arg GIT_NAME="$GIT_NAME" --build-arg GIT_EMAIL="$GIT_EMAIL" -t kaguya . +# Check if the image already exists and if the timestamp has changed +if [ "$(docker images -q $IMAGE_NAME 2> /dev/null)" == "" ] || [ ! -f "$TIMESTAMP_FILE" ] || [ "$MOD_TIMESTAMP" -gt "$(cat $TIMESTAMP_FILE)" ]; then + echo "Building the image..." + # Build the Docker image + docker build --build-arg GIT_NAME="$GIT_NAME" --build-arg GIT_EMAIL="$GIT_EMAIL" -t $IMAGE_NAME . + # Store the modification timestamp of Dockerfile + echo "$MOD_TIMESTAMP" > $TIMESTAMP_FILE +else + echo "Image exists and is up to date. Starting container..." +fi # Run the Docker container with the --rm flag (automatically remove container on exit) -docker run --shm-size=2g --rm -p 3000:3000 -v $(pwd):/kaguya -v /kaguya/node_modules kaguya +docker run --shm-size=2g --rm -p 9999:3000 -v $(pwd):/kaguya -v /kaguya/node_modules $IMAGE_NAME diff --git a/public/.well-known/ai-plugin.json b/public/.well-known/ai-plugin.json index 89e3181..3e6c8cb 100644 --- a/public/.well-known/ai-plugin.json +++ b/public/.well-known/ai-plugin.json @@ -9,7 +9,7 @@ }, "api": { "type": "openapi", - "url": "http://localhost:3000/openapi.yaml", + "url": "http://localhost:9999/openapi.yaml", "is_user_authenticated": false }, "logo_url": "https://images.squarespace-cdn.com/content/v1/59518b28cd0f684eae15259e/c8be2bdb-dd07-43ff-a268-db52c39925b0/csdlogo.jpg", diff --git a/public/openapi.yaml b/public/openapi.yaml index 4891152..0c37616 100644 --- a/public/openapi.yaml +++ b/public/openapi.yaml @@ -4,7 +4,7 @@ info: description: A project that you can edit just by talking to ChatGPT. version: v1 servers: - - url: http://localhost:3000 + - url: http://localhost:9999 paths: /api/executeCommand: post: