Skip to content

Commit

Permalink
Fix: Lock Down Docker Compose DB and NLP Ports (#249)
Browse files Browse the repository at this point in the history
* lock down docker compose db and nlp ports; dev docker compose

* remove log
  • Loading branch information
danielchalef committed Oct 30, 2023
1 parent 53c4822 commit babce2a
Show file tree
Hide file tree
Showing 4 changed files with 136 additions and 28 deletions.
77 changes: 55 additions & 22 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@ Thank you for your interest in contributing to Zep! We appreciate your efforts a

1. **Fork and Clone**: Start by forking the [Zep repo](https://github.com/getzep/zep). Then, clone your fork locally:

```
git clone https://github.com/<your-github-username>/zep.git
```
```
git clone https://github.com/<your-github-username>/zep.git
```

2. **Set Upstream**: Keep your fork synced with the upstream repo by adding it as a remote:

```
git remote add upstream https://github.com/getzep/zep.git
```
```
git remote add upstream https://github.com/getzep/zep.git
```

3. **Create a Feature Branch**: Always create a new branch for your work. This helps in keeping your changes organized and easier for maintainers to review.

```
git checkout -b feature/your-feature-name
```
```
git checkout -b feature/your-feature-name
```

### Setting "Development" Mode
"Development" mode forces Zep's log level to "debug" and disables caching of the web UI. This is useful when developing Zep locally.
Expand All @@ -34,21 +34,54 @@ export ZEP_DEVELOPMENT=true
or modify your `.env` file accordingly.


### Running the Database and NLP Server Stack

A development stack can be started by running:

```bash
make dev
```

This starts the DB and NLP services using docker compose and exposes the DB on port 5432 and the NLP service on port 5557.
The database volume is also not persistent, so it will be wiped out when the stack is stopped.

### Automatically Rebuilding Zep using Go Watch

**Note:** You will need to have [Go Watch](https://github.com/mitranim/gow) installed.

If you want to automatically rebuild Zep when you make changes to the code, run:

```
make watch
```

The above sets "Development" mode and binds Zep to localhost only.


### Rebuilding Tailwind CSS

If you make changes to the CSS used by HTML template files, you will need to rebuild the Tailwind CSS file.

Run:
```
make web
```

### Building Zep

Follow these steps to build Zep locally:

1. Navigate to the project root:

```
cd zep
```
```
cd zep
```

2. Build the project:

```
make build
```
```
make build
```

This will produce the binary in `./out/bin`.

Expand Down Expand Up @@ -86,16 +119,16 @@ make swagger

1. **Commit Your Changes**: Use meaningful commit messages that describe the changes made.

```
git add .
git commit -m "Your detailed commit message"
```
```
git add .
git commit -m "Your detailed commit message"
```

2. **Push to Your Fork**:

```
git push origin feature/your-feature-name
```
```
git push origin feature/your-feature-name
```

3. **Open a Pull Request**: Navigate to the [Zep GitHub repo](https://github.com/getzep/zep) and click on "New pull request". Choose your fork and the branch you've been working on. Submit the PR with a descriptive message.

Expand Down
9 changes: 7 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,15 @@ swagger:
lint:
golangci-lint run --deadline=90s --sort-results -c golangci.yaml

## Run the dev stack docker compose setup. This exposes DB and NLP services
## for local development. This does not start the Zep service.
dev:
docker compose -f docker-compose.dev.yaml up db nlp

## Go Watch for web development
## https://github.com/mitranim/gow
gow:
gow -e=go,mod,html,js,css -i=node_modules run .
watch:
ZEP_DEVELOPMENT=true ZEP_SERVER_HOST=localhost gow -e=go,mod,html,js,css -i=node_modules run .

# Build web assets
web:
Expand Down
74 changes: 74 additions & 0 deletions docker-compose.dev.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
version: "3.7"
services:
db:
image: ghcr.io/getzep/postgres:latest
container_name: zep-postgres
restart: on-failure
shm_size: "128mb" # Increase this if vacuuming fails with a "no space left on device" error
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
build:
context: .
dockerfile: Dockerfile.postgres
networks:
- zep-network
healthcheck:
test: [ "CMD", "pg_isready", "-q", "-d", "postgres", "-U", "postgres" ]
interval: 5s
timeout: 5s
retries: 5
ports:
- "5432:5432"
nlp:
image: ghcr.io/getzep/zep-nlp-server:latest
container_name: zep-nlp
env_file:
- .env # You can set your embedding-related variables here
restart: on-failure
networks:
- zep-network
healthcheck:
test: timeout 10s bash -c ':> /dev/tcp/127.0.0.1/5557' || exit 1
interval: 10s
timeout: 5s
retries: 5
start_period: 30s
ports:
- "5557:5557"
zep:
image: ghcr.io/getzep/zep:latest
container_name: zep
restart: on-failure
depends_on:
db:
condition: service_healthy
nlp:
condition: service_healthy
ports:
- "8000:8000"
volumes:
- ./config.yaml:/app/config.yaml
environment:
- ZEP_STORE_POSTGRES_DSN=postgres://postgres:postgres@db:5432/postgres?sslmode=disable
- ZEP_NLP_SERVER_URL=http://nlp:5557
- ZEP_EXTRACTORS_DOCUMENTS_EMBEDDINGS_SERVICE=openai
- ZEP_EXTRACTORS_DOCUMENTS_EMBEDDINGS_DIMENSIONS=1536
- ZEP_EXTRACTORS_MESSAGES_EMBEDDINGS_SERVICE=openai
- ZEP_EXTRACTORS_MESSAGES_EMBEDDINGS_DIMENSIONS=1536
env_file:
- .env # Store your OpenAI API key here as ZEP_OPENAI_API_KEY
build:
context: .
dockerfile: Dockerfile
healthcheck:
test: timeout 10s bash -c ':> /dev/tcp/127.0.0.1/8000' || exit 1
interval: 5s
timeout: 10s
retries: 3
start_period: 10s
networks:
- zep-network
networks:
zep-network:
driver: bridge
4 changes: 0 additions & 4 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ services:
interval: 5s
timeout: 5s
retries: 5
ports:
- "5432:5432"
nlp:
image: ghcr.io/getzep/zep-nlp-server:latest
container_name: zep-nlp
Expand All @@ -36,8 +34,6 @@ services:
timeout: 5s
retries: 5
start_period: 45s
ports:
- "5557:5557"
zep:
image: ghcr.io/getzep/zep:latest
container_name: zep
Expand Down

0 comments on commit babce2a

Please sign in to comment.