Skip to content

Commit

Permalink
[VectorSearch] Auto deploy model
Browse files Browse the repository at this point in the history
and update opensearch
  • Loading branch information
PierreGauthier committed May 13, 2024
1 parent 6d8b9c6 commit ec82325
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion api/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# https://docs.docker.com/engine/reference/builder/#understand-how-arg-and-from-interact
ARG PHP_VERSION=8.1
ARG CADDY_VERSION=2.6.4
ARG OPENSEARCH2_VERSION=2.11.0
ARG OPENSEARCH2_VERSION=2.13.0
ARG ELASTIC7_VERSION=7.16.3
ARG ELASTIC8_VERSION=8.10.4
# ARG XDEBUG_VERSION=3.1.2
Expand Down
27 changes: 27 additions & 0 deletions api/docker/php/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,33 @@ if [ "$1" = 'php-fpm' ] || [ "$1" = 'php' ] || [ "$1" = 'bin/console' ]; then

php bin/console doctrine:migrations:migrate --no-interaction
fi

if grep -q ELASTICSEARCH_URL= .env; then
echo "Waiting for search engine to be ready..."
ATTEMPTS_LEFT_TO_REACH_SEARCH=60
export $(grep 'ELASTICSEARCH_URL=' .env | xargs)
until [ $ ATTEMPTS_LEFT_TO_REACH_SEARCH -eq 0 ] || SEARCH_ERROR=$(curl -s ${ELASTICSEARCH_URL}); do
sleep 1
ATTEMPTS_LEFT_TO_REACH_SEARCH=$((ATTEMPTS_LEFT_TO_REACH_SEARCH - 1))
echo "Still waiting for search engine to be ready... Or maybe the search engine is not reachable. $ATTEMPTS_LEFT_TO_REACH_SEARCH attempts left."
done

if [ $ATTEMPTS_LEFT_TO_REACH_SEARCH -eq 0 ]; then
echo "The search engine is not up or not reachable:"
echo "$SEARCH_ERROR"
exit 1
else
echo "The search engine is now reachable"
fi

curl -s "${ELASTICSEARCH_URL}_cluster/health?wait_for_status=green&timeout=30s"
echo "The search engine is now ready"

if php bin/console list gally --raw | grep -q gally:vector-search:upload-model; then
echo "Load ml model in opensearch"
php bin/console gally:vector-search:upload-model
fi
fi
fi

exec docker-php-entrypoint "$@"

0 comments on commit ec82325

Please sign in to comment.