From ef1cd0fcb044e1a71e585a1903ed90b5615b9335 Mon Sep 17 00:00:00 2001 From: bracesproul Date: Wed, 3 Sep 2025 17:24:31 -0700 Subject: [PATCH 1/2] feat: Dockerize --- .dockerignore | 15 +++++ DOCKER.md | 121 +++++++++++++++++++++++++++++++++++++++ Dockerfile | 26 +++++++++ docker-compose.yml | 109 +++++++++++++++++++++++++++++++++++ docker/Dockerfile.node | 14 +++++ docker/Dockerfile.python | 19 ++++++ 6 files changed, 304 insertions(+) create mode 100644 .dockerignore create mode 100644 DOCKER.md create mode 100644 Dockerfile create mode 100644 docker-compose.yml create mode 100644 docker/Dockerfile.node create mode 100644 docker/Dockerfile.python diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..610c8b41 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,15 @@ +node_modules +.next +.git +.gitignore +README.md +Dockerfile +docker-compose.yml +.dockerignore +npm-debug.log* +yarn-debug.log* +yarn-error.log* +.env.local +.env.development.local +.env.test.local +.env.production.local \ No newline at end of file diff --git a/DOCKER.md b/DOCKER.md new file mode 100644 index 00000000..b162fb1e --- /dev/null +++ b/DOCKER.md @@ -0,0 +1,121 @@ +# Docker Setup for Open Agent Platform + +This Docker Compose setup allows you to run all required services locally with a single command. + +## Prerequisites + +1. Docker and Docker Compose installed +2. All external repositories cloned as siblings to this repo: + ``` + parent-directory/ + ├── open-agent-platform/ (this repo) + ├── deep-agent/ (port 2024) + ├── agent-optimizer/ (port 2025) + ├── triggers/ (port 8080) + ├── langconnect/ (port 8888) + └── tool-server/ (port 8000) + ``` + +## Setup + +### 1. Configure External Services + +Each external service needs a Dockerfile. Copy the appropriate template: + +**For Node.js services:** +```bash +cp docker/Dockerfile.node ../service-name/Dockerfile +``` + +**For Python services:** +```bash +cp docker/Dockerfile.python ../service-name/Dockerfile +``` + +### 2. Update Docker Compose + +Edit `docker-compose.yml` and: +- Adjust the `context` paths to match your repo locations +- Uncomment Python service commands for Python-based services +- Remove `/app/node_modules` volume mounts for Python services +- Add any service-specific environment variables + +### 3. Environment Variables + +Copy and configure environment files: +```bash +cp apps/web/.env.example apps/web/.env +``` + +Update the environment variables in `.env` and `docker-compose.yml` as needed. + +## Usage + +### Start all services +```bash +docker-compose up +``` + +### Start with rebuild +```bash +docker-compose up --build +``` + +### Start in background +```bash +docker-compose up -d +``` + +### View logs +```bash +docker-compose logs -f [service-name] +``` + +### Stop all services +```bash +docker-compose down +``` + +## Service Ports + +- **web**: http://localhost:3000 (this repo) +- **deep-agent**: http://localhost:2024 +- **agent-optimizer**: http://localhost:2025 +- **triggers**: http://localhost:8080 +- **langconnect**: http://localhost:8888 +- **tool-server**: http://localhost:8000 + +## Hot Reloading + +All services are configured with volume mounts to enable hot reloading: +- Source code changes will automatically trigger rebuilds +- Node modules are cached in anonymous volumes for performance + +## Troubleshooting + +### Service won't start +1. Check if the external repo path exists +2. Verify the Dockerfile exists in the external repo +3. Check service logs: `docker-compose logs [service-name]` + +### Port conflicts +If ports are already in use, update the port mappings in `docker-compose.yml`: +```yaml +ports: + - "NEW_PORT:ORIGINAL_PORT" +``` + +### Dependencies not installing +For Node.js services, ensure `package.json` exists in the external repo root. +For Python services, ensure `requirements.txt` exists in the external repo root. + +## Customization + +### Adding environment variables +Add them to the `environment` section of each service in `docker-compose.yml`. + +### Changing start commands +Update the `command` field for each service in `docker-compose.yml`. + +### Adding new services +Follow the same pattern as existing services in `docker-compose.yml`. \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..fb203d02 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,26 @@ +FROM node:20-alpine + +WORKDIR /app + +# Install dependencies +COPY package.json yarn.lock ./ +COPY .yarn .yarn +COPY .yarnrc.yml .yarnrc.yml + +# Copy package.json files for all workspaces +COPY apps/web/package.json ./apps/web/ +COPY apps/docs/package.json ./apps/docs/ +COPY packages/*/package.json ./packages/*/ +COPY turbo.json ./ + +# Install all dependencies +RUN yarn install --frozen-lockfile + +# Copy source code +COPY . . + +# Expose port for the web app +EXPOSE 3000 + +# Start the development server +CMD ["yarn", "dev"] \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..04e94ef5 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,109 @@ +version: '3.8' + +services: + # Main web application (this repo) + web: + build: . + ports: + - "3000:3000" + volumes: + # Mount source code for hot reloading + - .:/app + - /app/node_modules + - /app/.next + environment: + - NODE_ENV=development + - NEXT_PUBLIC_BASE_API_URL=http://localhost:3000/api + - NEXT_PUBLIC_RAG_API_URL=http://localhost:8080 + depends_on: + - deep-agent + - agent-optimizer + - triggers + - langconnect + - tool-server + networks: + - open-agent-network + + # Deep agent service (external repo) + deep-agent: + build: + context: ../deep-agent # Adjust path to your deep-agent repo + ports: + - "2024:2024" + volumes: + - ../deep-agent:/app + - /app/node_modules # If JS/TS + environment: + - NODE_ENV=development + networks: + - open-agent-network + # Uncomment if it's a Python service: + # command: python -m uvicorn main:app --host 0.0.0.0 --port 2024 --reload + + # Agent optimizer service (external repo) + agent-optimizer: + build: + context: ../agent-optimizer # Adjust path to your agent-optimizer repo + ports: + - "2025:2025" + volumes: + - ../agent-optimizer:/app + - /app/node_modules # If JS/TS + environment: + - NODE_ENV=development + networks: + - open-agent-network + # Uncomment if it's a Python service: + # command: python -m uvicorn main:app --host 0.0.0.0 --port 2025 --reload + + # Triggers service (external repo) + triggers: + build: + context: ../triggers # Adjust path to your triggers repo + ports: + - "8080:8080" + volumes: + - ../triggers:/app + - /app/node_modules # If JS/TS + environment: + - NODE_ENV=development + networks: + - open-agent-network + # Uncomment if it's a Python service: + # command: python -m uvicorn main:app --host 0.0.0.0 --port 8080 --reload + + # LangConnect service (external repo) + langconnect: + build: + context: ../langconnect # Adjust path to your langconnect repo + ports: + - "8888:8888" + volumes: + - ../langconnect:/app + - /app/node_modules # If JS/TS + environment: + - NODE_ENV=development + networks: + - open-agent-network + # Uncomment if it's a Python service: + # command: python -m uvicorn main:app --host 0.0.0.0 --port 8888 --reload + + # Tool server service (external repo) + tool-server: + build: + context: ../tool-server # Adjust path to your tool-server repo + ports: + - "8000:8000" + volumes: + - ../tool-server:/app + - /app/node_modules # If JS/TS + environment: + - NODE_ENV=development + networks: + - open-agent-network + # Uncomment if it's a Python service: + # command: python -m uvicorn main:app --host 0.0.0.0 --port 8000 --reload + +networks: + open-agent-network: + driver: bridge \ No newline at end of file diff --git a/docker/Dockerfile.node b/docker/Dockerfile.node new file mode 100644 index 00000000..254dfa1c --- /dev/null +++ b/docker/Dockerfile.node @@ -0,0 +1,14 @@ +# Example Dockerfile for Node.js services +FROM node:20-alpine + +WORKDIR /app + +# Install dependencies +COPY package*.json ./ +RUN npm install + +# Copy source code +COPY . . + +# Default command (override in docker-compose.yml if needed) +CMD ["npm", "run", "dev"] \ No newline at end of file diff --git a/docker/Dockerfile.python b/docker/Dockerfile.python new file mode 100644 index 00000000..75c154ca --- /dev/null +++ b/docker/Dockerfile.python @@ -0,0 +1,19 @@ +# Example Dockerfile for Python services +FROM python:3.11-slim + +WORKDIR /app + +# Install system dependencies +RUN apt-get update && apt-get install -y \ + gcc \ + && rm -rf /var/lib/apt/lists/* + +# Install Python dependencies +COPY requirements.txt ./ +RUN pip install --no-cache-dir -r requirements.txt + +# Copy source code +COPY . . + +# Default command (override in docker-compose.yml if needed) +CMD ["python", "main.py"] \ No newline at end of file From 71c696275f11cc24f035826bac72843053f1ab96 Mon Sep 17 00:00:00 2001 From: bracesproul Date: Mon, 8 Sep 2025 08:54:43 -0700 Subject: [PATCH 2/2] cr --- DOCKER.md | 4 +- Dockerfile | 19 ++-- docker-compose.yml | 98 ++++++++++++------- .../{Dockerfile.node => Dockerfile.oap.node} | 0 ...ockerfile.python => Dockerfile.oap.python} | 0 5 files changed, 73 insertions(+), 48 deletions(-) rename docker/{Dockerfile.node => Dockerfile.oap.node} (100%) rename docker/{Dockerfile.python => Dockerfile.oap.python} (100%) diff --git a/DOCKER.md b/DOCKER.md index b162fb1e..c453690f 100644 --- a/DOCKER.md +++ b/DOCKER.md @@ -24,12 +24,12 @@ Each external service needs a Dockerfile. Copy the appropriate template: **For Node.js services:** ```bash -cp docker/Dockerfile.node ../service-name/Dockerfile +cp docker/Dockerfile.oap.node ../service-name/Dockerfile.oap ``` **For Python services:** ```bash -cp docker/Dockerfile.python ../service-name/Dockerfile +cp docker/Dockerfile.oap.python ../service-name/Dockerfile.oap ``` ### 2. Update Docker Compose diff --git a/Dockerfile b/Dockerfile index fb203d02..f8eaeee6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,26 +1,23 @@ FROM node:20-alpine +# Install build dependencies for native modules +RUN apk add --no-cache make gcc g++ python3 + WORKDIR /app -# Install dependencies COPY package.json yarn.lock ./ COPY .yarn .yarn COPY .yarnrc.yml .yarnrc.yml -# Copy package.json files for all workspaces -COPY apps/web/package.json ./apps/web/ -COPY apps/docs/package.json ./apps/docs/ -COPY packages/*/package.json ./packages/*/ +COPY apps/ ./apps/ +COPY packages/ ./packages/ COPY turbo.json ./ -# Install all dependencies -RUN yarn install --frozen-lockfile +RUN corepack enable +RUN yarn install --immutable -# Copy source code COPY . . -# Expose port for the web app EXPOSE 3000 -# Start the development server -CMD ["yarn", "dev"] \ No newline at end of file +CMD ["yarn", "dev"] diff --git a/docker-compose.yml b/docker-compose.yml index 04e94ef5..4ca0e3fa 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,7 +3,9 @@ version: '3.8' services: # Main web application (this repo) web: - build: . + build: + context: . + dockerfile: Dockerfile ports: - "3000:3000" volumes: @@ -11,15 +13,13 @@ services: - .:/app - /app/node_modules - /app/.next - environment: - - NODE_ENV=development - - NEXT_PUBLIC_BASE_API_URL=http://localhost:3000/api - - NEXT_PUBLIC_RAG_API_URL=http://localhost:8080 + env_file: + - apps/web/.env depends_on: - deep-agent - agent-optimizer - triggers - - langconnect + - langconnect-oap - tool-server networks: - open-agent-network @@ -27,82 +27,110 @@ services: # Deep agent service (external repo) deep-agent: build: - context: ../deep-agent # Adjust path to your deep-agent repo + context: ../deep-agent + dockerfile: Dockerfile ports: - "2024:2024" volumes: - ../deep-agent:/app - /app/node_modules # If JS/TS - environment: - - NODE_ENV=development + env_file: + - ../deep-agent/.env networks: - open-agent-network - # Uncomment if it's a Python service: - # command: python -m uvicorn main:app --host 0.0.0.0 --port 2024 --reload # Agent optimizer service (external repo) agent-optimizer: build: - context: ../agent-optimizer # Adjust path to your agent-optimizer repo + context: ../agent-optimizer + dockerfile: Dockerfile ports: - "2025:2025" volumes: - ../agent-optimizer:/app - /app/node_modules # If JS/TS - environment: - - NODE_ENV=development + env_file: + - ../agent-optimizer/.env networks: - open-agent-network - # Uncomment if it's a Python service: - # command: python -m uvicorn main:app --host 0.0.0.0 --port 2025 --reload # Triggers service (external repo) triggers: build: - context: ../triggers # Adjust path to your triggers repo + context: ../triggers + dockerfile: Dockerfile ports: - "8080:8080" volumes: - ../triggers:/app - /app/node_modules # If JS/TS + env_file: + - ../triggers/.env + networks: + - open-agent-network + + # LangConnect PostgreSQL database + langconnect-postgres-oap: + image: pgvector/pgvector:pg16 + container_name: langconnect-postgres-oap + restart: always + ports: + - "5432:5432" environment: - - NODE_ENV=development + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + POSTGRES_DB: postgres + volumes: + - langconnect_postgres_data:/var/lib/postgresql/data + healthcheck: + test: ["CMD", "pg_isready", "-U", "postgres"] + interval: 5s + timeout: 5s + retries: 5 networks: - open-agent-network - # Uncomment if it's a Python service: - # command: python -m uvicorn main:app --host 0.0.0.0 --port 8080 --reload - # LangConnect service (external repo) - langconnect: + # LangConnect API service (external repo) + langconnect-oap: build: - context: ../langconnect # Adjust path to your langconnect repo + context: ../langconnect + dockerfile: Dockerfile + container_name: langconnect-api-oap + restart: always + depends_on: + langconnect-postgres-oap: + condition: service_healthy ports: - "8888:8888" - volumes: - - ../langconnect:/app - - /app/node_modules # If JS/TS + env_file: + - ../langconnect/.env environment: - - NODE_ENV=development + POSTGRES_HOST: langconnect-postgres-oap + POSTGRES_PORT: 5432 + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + POSTGRES_DB: postgres + volumes: + - ../langconnect/langconnect:/app/langconnect networks: - open-agent-network - # Uncomment if it's a Python service: - # command: python -m uvicorn main:app --host 0.0.0.0 --port 8888 --reload # Tool server service (external repo) tool-server: build: - context: ../tool-server # Adjust path to your tool-server repo + context: ../tool-server + dockerfile: Dockerfile ports: - "8000:8000" volumes: - ../tool-server:/app - - /app/node_modules # If JS/TS - environment: - - NODE_ENV=development + env_file: + - ../tool-server/.env networks: - open-agent-network - # Uncomment if it's a Python service: - # command: python -m uvicorn main:app --host 0.0.0.0 --port 8000 --reload + +volumes: + langconnect_postgres_data: networks: open-agent-network: diff --git a/docker/Dockerfile.node b/docker/Dockerfile.oap.node similarity index 100% rename from docker/Dockerfile.node rename to docker/Dockerfile.oap.node diff --git a/docker/Dockerfile.python b/docker/Dockerfile.oap.python similarity index 100% rename from docker/Dockerfile.python rename to docker/Dockerfile.oap.python