Docker Compose for LangChain + PostgreSQL
LangChain application with PostgreSQL for vector storage. Build AI agents and RAG apps.
python langchain ai postgres llm
compose.yaml
services:
app:
build: .
ports:
- target: 8000
mode: ingress
environment:
- DATABASE_URL=postgresql://postgres:${POSTGRES_PASSWORD}@db:5432/langchain
- OPENAI_API_KEY=${OPENAI_API_KEY}
healthcheck:
test:
- CMD
- curl
- -f
- http://localhost:8000/
interval: 30s
timeout: 5s
retries: 3
depends_on:
- db
deploy:
resources:
reservations:
cpus: "1"
memory: 1G
restart: unless-stopped
db:
image: pgvector/pgvector:pg16
ports:
- target: 5432
mode: host
environment:
- POSTGRES_DB=langchain
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
healthcheck:
test:
- CMD-SHELL
- pg_isready -U postgres
interval: 10s
timeout: 5s
retries: 5
deploy:
resources:
reservations:
cpus: "0.5"
memory: 256M
restart: unless-stopped
x-defang-postgres: true
Services
- app .
- db pgvector/pgvector:pg16