Skip to content

Commit

Permalink
🚀 feat: add docker-compose support (#301)
Browse files Browse the repository at this point in the history
* feat: add docker-compose support

* feat: add docker-compose support for docker-compose.yml

* nits for docker compose

---------

Co-authored-by: Shreya Shankar <ss.shankar505@gmail.com>
  • Loading branch information
Sunwood-ai-labs and shreyashankar authored Feb 4, 2025
1 parent 79b5934 commit d7eef7d
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 6 deletions.
10 changes: 8 additions & 2 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@

# BACKEND configuration
BACKEND_ALLOW_ORIGINS=http://localhost:3000,http://127.0.0.1:3000
BACKEND_HOST=localhost
BACKEND_PORT=8000
BACKEND_RELOAD=True

# FRONTEND configuration
FRONTEND_HOST=0.0.0.0
FRONTEND_PORT=3000

TEXT_FILE_ENCODINGS=utf-8,latin1,cp1252,iso-8859-1
# Host port mapping for docker-compose (if not set, defaults are used in docker-compose.yml)
FRONTEND_DOCKER_COMPOSE_PORT=3031
BACKEND_DOCKER_COMPOSE_PORT=8081

# Supported text file encodings
TEXT_FILE_ENCODINGS=utf-8,latin1,cp1252,iso-8859-1
43 changes: 43 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
services:
docetl:
container_name: docetl-docwrangler-stack
build: .
image: docetl
restart: unless-stopped
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8000/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
ports:
# Map host ports to container ports using environment variables.
# If FRONTEND_DOCKER_COMPOSE_PORT is not set, default to 3031.
- "${FRONTEND_DOCKER_COMPOSE_PORT:-3031}:3000"
# If BACKEND_DOCKER_COMPOSE_PORT is not set, default to 8081.
- "${BACKEND_DOCKER_COMPOSE_PORT:-8081}:8000"
environment:
# Pass environment variables from the .env file (or host environment)
# with default values if they are not defined.
# Authentication
- OPENAI_API_KEY=${OPENAI_API_KEY:-your_api_key_here}

# Backend Configuration
- BACKEND_ALLOW_ORIGINS=${BACKEND_ALLOW_ORIGINS:-http://localhost:3000,http://127.0.0.1:3000}
- BACKEND_HOST=${BACKEND_HOST:-0.0.0.0}
- BACKEND_PORT=${BACKEND_PORT:-8000}
- BACKEND_RELOAD=${BACKEND_RELOAD:-True}

# Frontend Configuration
- FRONTEND_HOST=${FRONTEND_HOST:-0.0.0.0}
- FRONTEND_PORT=${FRONTEND_PORT:-3000}

# File Processing
- TEXT_FILE_ENCODINGS=${TEXT_FILE_ENCODINGS:-utf-8,latin1,cp1252,iso-8859-1}
volumes:
# Mount the named volume "docetl-data" to /docetl-data in the container.
- docetl-data:/docetl-data

volumes:
# Define a named volume for persistent data.
docetl-data:
6 changes: 5 additions & 1 deletion server/app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
allow_headers=["*"],
)

# Include all routers
# Include all routers,
app.include_router(pipeline.router)
app.include_router(convert.router)
app.include_router(filesystem.router, prefix="/fs")
Expand All @@ -35,6 +35,10 @@
async def root():
return {"message": "DocETL API is running"}

@app.get("/health")
async def health_check():
return {"status": "healthy"}

if __name__ == "__main__":
import uvicorn
uvicorn.run("server.app.main:app", host=host, port=port, reload=reload)
4 changes: 2 additions & 2 deletions website/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion website/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "docet-website",
"name": "docwrangler",
"version": "0.1.0",
"private": true,
"scripts": {
Expand Down

0 comments on commit d7eef7d

Please sign in to comment.