Host NekoImageGallery
NekoImageGallery is an image gallery service that provides image search and image similarity search. It is a service that provides image search and image similarity search. It is an alternative to the proprietary image search services, to provide image search and image similarity search from a dedicated server to end-user devices via multiple apps.
To host NekoImageGallery on AnduinOS, run the following commands.
First, make sure Docker is installed on your machine. If not, you can install Docker by running the following commands:
curl -fsSL get.docker.com -o get-docker.sh
CHANNEL=stable sh get-docker.sh
rm get-docker.sh
Create a new folder to save the service configuration files:
# Please install Docker first
mkdir -p ~/Source/ServiceConfigs/NekoImageGallery
cd ~/Source/ServiceConfigs/NekoImageGallery
Make sure no other process is taking 8000, and 5000 ports on your machine.
function port_exist_check() {
if [[ 0 -eq $(sudo lsof -i:"$1" | grep -i -c "listen") ]]; then
echo "$1 is not in use"
sleep 1
else
echo "Warning: $1 is occupied"
sudo lsof -i:"$1"
echo "Will kill the occupied process in 5s"
sleep 5
sudo lsof -i:"$1" | awk '{print $2}' | grep -v "PID" | sudo xargs kill -9
echo "Killed the occupied process"
sleep 1
fi
}
port_exist_check 8000
port_exist_check 5000
Then, create a docker-compose.yml
file with the following content:
cat << EOF > ./docker-compose.yml
version: '3.3'
services:
webapp:
image: hub.aiursoft.cn/edgeneko/nekoimagegallery.app
ports:
- target: 5000
published: 5000
protocol: tcp
mode: host
environment:
- OVERRIDE_API_URL=http://localhost:8000
server:
image: hub.aiursoft.cn/edgeneko/neko-image-gallery:latest-cpu
ports:
- target: 8000
published: 8000
protocol: tcp
mode: host
networks:
- internal
volumes:
- neko-image-gallery-local:/opt/NekoImageGallery/static
depends_on:
- qdrant_database
environment:
- APP_ACCESS_PROTECTED=True
- APP_QDRANT__COLL=NekoImg-v4
- APP_QDRANT__HOST=qdrant_database
- APP_OCR_SEARCH__OCR_MIN_CONFIDENCE=0.05
- APP_ADMIN_API_ENABLE=True
- APP_STORAGE__METHOD=local
secrets:
- source: neko-image-gallery-access-token
target: app_access_token
- source: neko-image-gallery-admin-token
target: app_admin_token
qdrant_database:
image: qdrant/qdrant
networks:
- internal
volumes:
- neko-image-gallery-vector-db:/qdrant/storage:z
volumes:
neko-image-gallery-vector-db:
driver: local
driver_opts:
type: none
o: bind
device: /swarm-vol/neko-image-gallery/vector_db
neko-image-gallery-local:
driver: local
driver_opts:
type: none
o: bind
device: /swarm-vol/neko-image-gallery/local_images/
networks:
internal:
driver: overlay
secrets:
neko-image-gallery-access-token:
external: true
neko-image-gallery-admin-token:
external: true
EOF
sudo mkdir -p /swarm-vol/neko-image-gallery/vector_db
sudo mkdir -p /swarm-vol/neko-image-gallery/local_images
You need to create two secrets for the service. Run the following commands to create the secrets:
sudo docker swarm init --advertise-addr $(hostname -I | awk '{print $1}')
function create_secret() {
secret_name=$1
known_secrets=$(sudo docker secret ls --format '{{.Name}}')
if [[ $known_secrets != *"$secret_name"* ]]; then
echo "Please enter $secret_name secret"
read secret_value
echo $secret_value | sudo docker secret create $secret_name -
fi
}
create_secret neko-image-gallery-access-token
create_secret neko-image-gallery-admin-token
Then, deploy the service:
sudo docker stack deploy -c docker-compose.yml neko-image-gallery --detach
That's it! You have successfully hosted NekoImageGallery on AnduinOS.
You can access NekoImageGallery by visiting http://localhost:5000
in your browser.
The default password is set as the secret you created during the deployment.
Import photos
You can upload photos to NekoImageGallery through the web portal.
To get started, visit http://localhost:5000. Click the Settings
button located at the top right corner. Enable the Use admin portal
option by toggling the switch, and then enter the admin token you previously set, as shown below:
Next, click the Upload
button at the top right corner. Select the images you wish to upload, and then click Upload
. Your images will be uploaded to the server and queued for indexing. Once the images are indexed, they will appear in the search results.
You can checkout the official documentation for more information.
Uninstall
To uninstall NekoImageGallery, run the following commands:
sudo docker stack rm neko-image-gallery
sleep 20 # Wait for the stack to be removed
sudo docker system prune -a --volumes -f # Clean up used volumes and images
To also remove the data, log, and config files, run the following commands:
sudo rm /swarm-vol/neko-image-gallery -rf
That's it! You have successfully uninstalled NekoImageGallery from AnduinOS.