Skip to content

Commit

Permalink
add docker test
Browse files Browse the repository at this point in the history
Signed-off-by: Adrian Cole <[email protected]>
  • Loading branch information
codefromthecrypt committed Feb 20, 2025
1 parent 3873ccd commit 1bfc9ea
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 10 deletions.
28 changes: 27 additions & 1 deletion .github/workflows/docker-chatbot-rag-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ on:
branches:
- main
paths:
# Verify changes to the Dockerfile on PRs
# Verify changes to the Dockerfile on PRs, tainted when we update ES.
- docker/docker-compose-elastic.yml
- example-apps/chatbot-rag-app/docker-compose.yml
- example-apps/chatbot-rag-app/Dockerfile
- .github/workflows/docker-chatbot-rag-app.yml
- '!**/*.md'
Expand Down Expand Up @@ -64,6 +66,30 @@ jobs:
if-no-files-found: error
retention-days: 1

# This tests the chatbot-rag-app image by running the create-index command.
# This command only relies on Elasticsearch, and verifies ELSER is working.
test-image:
strategy:
matrix:
runner:
- ubuntu-24.04
- ubuntu-24.04-arm
needs: build-image
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: start elasticsearch
run: docker compose -f docker/docker-compose-elastic.yml up elasticsearch -d --wait --wait-timeout 120
- name: test image
working-directory: example-apps/chatbot-rag-app
run: |
echo "Testing image ${IMAGE}"
cp env.example .env
docker compose run --rm -T create-index
env:
IMAGE: ${{ steps.build.outputs.digest }}

push-manifest:
runs-on: ubuntu-24.04
needs: build-image
Expand Down
2 changes: 1 addition & 1 deletion docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ wget https://raw.githubusercontent.com/elastic/elasticsearch-labs/refs/heads/mai
Use docker compose to run Elastic stack in the background:

```bash
docker compose -f docker-compose-elastic.yml up --force-recreate -d
docker compose -f docker-compose-elastic.yml up --force-recreate --wait -d
```

Then, you can view Kibana at http://localhost:5601/app/home#/
Expand Down
11 changes: 6 additions & 5 deletions docker/docker-compose-elastic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: elastic-stack

services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:8.17.0
image: docker.elastic.co/elasticsearch/elasticsearch:8.17.2
container_name: elasticsearch
ports:
- 9200:9200
Expand All @@ -16,7 +16,8 @@ services:
- xpack.security.http.ssl.enabled=false
- xpack.security.transport.ssl.enabled=false
- xpack.license.self_generated.type=trial
# Use minimum heap required by ELSER
# Note that ELSER is recommended to have 2GB, but it is JNI (PyTorch).
# So, ELSER's memory is in addition to the heap and other overhead.
- ES_JAVA_OPTS=-Xms2g -Xmx2g
ulimits:
memlock:
Expand All @@ -37,7 +38,7 @@ services:
depends_on:
elasticsearch:
condition: service_healthy
image: docker.elastic.co/elasticsearch/elasticsearch:8.17.0
image: docker.elastic.co/elasticsearch/elasticsearch:8.17.2
container_name: elasticsearch_settings
restart: 'no'
command: >
Expand All @@ -49,7 +50,7 @@ services:
'
kibana:
image: docker.elastic.co/kibana/kibana:8.17.0
image: docker.elastic.co/kibana/kibana:8.17.2
container_name: kibana
depends_on:
elasticsearch_settings:
Expand All @@ -73,7 +74,7 @@ services:
interval: 1s

apm-server:
image: docker.elastic.co/apm/apm-server:8.17.0
image: docker.elastic.co/apm/apm-server:8.17.2
container_name: apm-server
depends_on:
elasticsearch:
Expand Down
8 changes: 7 additions & 1 deletion example-apps/chatbot-rag-app/api/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
get_elasticsearch_chat_message_history,
)
from flask import current_app, render_template, stream_with_context
from functools import cache
from langchain_elasticsearch import (
ElasticsearchStore,
SparseVectorStrategy,
Expand All @@ -27,11 +28,16 @@
strategy=SparseVectorStrategy(model_id=ELSER_MODEL),
)

llm = get_llm()

@cache
def get_lazy_llm():
return get_llm()


@stream_with_context
def ask_question(question, session_id):
llm = get_lazy_llm()

yield f"data: {SESSION_ID_TAG} {session_id}\n\n"
current_app.logger.debug("Chat session ID: %s", session_id)

Expand Down
4 changes: 2 additions & 2 deletions example-apps/chatbot-rag-app/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: chatbot-rag-app

services:
create-index:
image: ghcr.io/elastic/elasticsearch-labs/chatbot-rag-app
image: ${IMAGE:-ghcr.io/elastic/elasticsearch-labs/chatbot-rag-app}
build:
context: .
container_name: create-index
Expand All @@ -21,7 +21,7 @@ services:
create-index:
condition: service_completed_successfully
container_name: api-frontend
image: ghcr.io/elastic/elasticsearch-labs/chatbot-rag-app
image: ${IMAGE:-ghcr.io/elastic/elasticsearch-labs/chatbot-rag-app}
build:
context: .
env_file:
Expand Down

0 comments on commit 1bfc9ea

Please sign in to comment.