I am attempting to use docker compose on an open source project to containerize my python API, a nextjs web app, and a pgvector database. I am able to run docker compose, my images build, and the web app seems to interface with the API container for all of my requests except text/event-stream
s.
I believe that my API can handle this—when I connect my web app locally to the API docker image, it processes these streaming events without issue—but when I try to make the request from my web app image it fails with the following network response and no indication that the response was sent to the API.
{
"error": "Error fetching data",
"message": "Network Error",
"stack": "AxiosError: Network Error\n at fetch (/app/.next/server/pages/api/rag-completion.js:24:89961)\n at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n at async e8.request (/app/.next/server/pages/api/rag-completion.js:24:92487)\n at e8.request (/app/.next/server/pages/api/rag-completion.js:24:92580)\n at process.processTicksAndRejections (node:internal/process/task_queues:95:5)"
}
This leads me to believe that there might be an issue with how I define the network in my Docker Compose file, however I’ve not been able to pin down any specific reason why streaming wouldn’t be supported. Most references to this are from ~2017, and seem to be unresolved.
My compose.yaml is as follows:
networks:
r2r-network:
driver: bridge
services:
r2r:
image: emrgntcmplxty/r2r:main
ports:
- "8000:8000"
environment:
- OPENAI_API_KEY=${OPENAI_API_KEY}
- POSTGRES_USER=${POSTGRES_USER:-postgres}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-postgres}
- POSTGRES_HOST=postgres
- POSTGRES_PORT=5432
- POSTGRES_DBNAME=${POSTGRES_DBNAME:-postgres}
depends_on:
- postgres
networks:
- r2r-network
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8000/health"]
interval: 10s
timeout: 5s
retries: 5
r2r-dashboard:
image: emrgntcmplxty/r2r-dashboard:latest
ports:
- "3000:3000"
depends_on:
- r2r
networks:
- r2r-network
postgres:
image: pgvector/pgvector:pg16
environment:
POSTGRES_USER: ${POSTGRES_USER:-postgres}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-postgres}
POSTGRES_DB: ${POSTGRES_DBNAME:-postgres}
ports:
- "5432:5432"
volumes:
- postgres_data:/var/lib/postgresql/data
networks:
- r2r-network
volumes:
postgres_data:
And if it is helpful to see the Dockerfiles, they can be found here:
Does anyone have experience with streaming issues between containers in Docker Compose? Are there any specific configurations or settings I should look into to resolve this issue? I greatly appreciate any insights!