Skip to content

Commit

Permalink
fix local docker
Browse files Browse the repository at this point in the history
  • Loading branch information
rbs333 committed Jan 31, 2025
1 parent 173a077 commit 4631209
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 17 deletions.
30 changes: 22 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,20 +91,23 @@ The dataset was taken from the the following Kaggle links.
- [Large Dataset](https://www.kaggle.com/datasets/paramaggarwal/fashion-product-images-dataset)
- [Smaller Dataset](https://www.kaggle.com/datasets/paramaggarwal/fashion-product-images-small)

A formatted version is available for use with this demo at:


## Running the App with docker-compose
Before running the app, install [Docker Desktop](https://www.docker.com/products/docker-desktop/).

#### Using Redis Cloud (recommended)
#### Using Redis Cloud

1. [Get your Redis Cloud Database](https://app.redislabs.com/) (if needed).

2. Export Redis Endpoint Environment Variables:
```bash
$ export REDIS_HOST=your-redis-host
$ export REDIS_PORT=your-redis-port
$ export REDIS_PASSOWRD=your-redis-password
```
2. `touch .env` and update with cloud values

```bash
REDIS_HOST=your-redis-host
REDIS_PORT=your-redis-port
REDIS_PASSOWRD=your-redis-password
```

3. Run the App:
```bash
Expand All @@ -113,11 +116,22 @@ Before running the app, install [Docker Desktop](https://www.docker.com/products

> The benefit of this approach is that the db will persist beyond application runs. So you can make updates and re run the app without having to provision the dataset or create another search index.

#### Using Redis Docker
#### Running the app locally using docker

1. `touch .env` and update with local values

```bash
REDIS_HOST=redis
REDIS_PORT=6379
```

2. Run compose command
```bash
$ docker compose -f docker-local-redis.yml up
```

Note: you can add `--build` and `--force-recreate` if caching old images.

## Running without docker-compose

### Run frontend
Expand Down
1 change: 1 addition & 0 deletions backend/productsearch/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
API_DOCS = "/api/docs"
OPENAPI_DOCS = "/api/openapi.json"
INDEX_NAME = "products"

REDIS_HOST = os.environ.get("REDIS_HOST", "redis-vector-db")
REDIS_PORT = os.environ.get("REDIS_PORT", 6379)
REDIS_DB = os.environ.get("REDIS_DB", 0)
Expand Down
5 changes: 2 additions & 3 deletions backend/productsearch/db/load.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
#!/usr/bin/env python3
import asyncio
import json
import requests
import os
from typing import List

import numpy as np
from redisvl.index import AsyncSearchIndex

import requests
from productsearch import config
from redisvl.index import AsyncSearchIndex


def read_from_s3():
Expand Down
8 changes: 2 additions & 6 deletions docker-local-redis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,10 @@ services:
- "6379:6379"
- "8001:8001"
volumes:
- redis-vector-db:/data
- ./data:/app/data
healthcheck:
test: ["CMD", "redis-cli", "-h", "localhost", "-p", "6379", "ping"]
interval: 2s
timeout: 1m30s
retries: 5
start_period: 5s


volumes:
redis-vector-db:
start_period: 5s

0 comments on commit 4631209

Please sign in to comment.