Merge pull request #3 from josedario87/revert-2-feat/docker-compose-setup
Revert "feat: Initial Docker Compose setup for conversation layer"
This commit is contained in:
72
README.md
72
README.md
@@ -1,71 +1 @@
|
|||||||
# conversation-layer
|
# conversation-layer
|
||||||
|
|
||||||
## Conversation Layer System
|
|
||||||
|
|
||||||
This repository contains the services for the conversation layer, managed by Docker Compose. It includes:
|
|
||||||
|
|
||||||
* **OpenWA:** Handles WhatsApp communication.
|
|
||||||
* **Chat UI:** Provides a user interface for conversations.
|
|
||||||
* **WhatsApp Router:** Connects OpenWA to the Chat UI and an LLM agent.
|
|
||||||
|
|
||||||
## Prerequisites
|
|
||||||
|
|
||||||
* Docker (https://www.docker.com/get-started)
|
|
||||||
* Docker Compose (usually included with Docker Desktop)
|
|
||||||
|
|
||||||
## Setup and Running
|
|
||||||
|
|
||||||
1. **Clone the repository:**
|
|
||||||
```bash
|
|
||||||
git clone <your-repo-url>
|
|
||||||
cd <your-repo-directory>
|
|
||||||
```
|
|
||||||
|
|
||||||
2. **Configure OpenWA:**
|
|
||||||
* Open the `docker-compose.yml` file.
|
|
||||||
* **Crucial:** Locate the `openwa` service definition. You may need to replace the placeholder image `image: devlikeapro/open-wa-api:latest` with the specific OpenWA Docker image you intend to use.
|
|
||||||
* Consult the documentation for your chosen OpenWA image to set necessary environment variables under `services.openwa.environment`. For example, you'll likely need to configure the `WEBHOOK_URL` that OpenWA should call. The `whatsapp-router` service expects this webhook at `http://whatsapp-router:3001/webhook`. So, an example for OpenWA's configuration might be `WEBHOOK_URL=http://whatsapp-router:3001/webhook`.
|
|
||||||
* Adjust port mappings for `openwa` if your image uses different ports than the defaults provided (API `8080`, Webhook `3000`).
|
|
||||||
|
|
||||||
3. **Configure Service Endpoints (if necessary):**
|
|
||||||
* **Chat UI (`chat-ui` service):** If the Chat UI needs to know the endpoint of your LLM agent, set the `LLM_AGENT_URL` (or similar) environment variable in `docker-compose.yml` under `services.chat-ui.environment`.
|
|
||||||
* **WhatsApp Router (`whatsapp-router` service):** This service is pre-configured to look for OpenWA at `http://openwa:8080`. If your LLM agent is called by the router, set its URL via an environment variable like `LLM_AGENT_URL` under `services.whatsapp-router.environment`.
|
|
||||||
|
|
||||||
4. **Build and run the services:**
|
|
||||||
```bash
|
|
||||||
docker-compose up --build
|
|
||||||
```
|
|
||||||
* The `--build` flag ensures images are built if they don't exist or if Dockerfiles/contexts have changed.
|
|
||||||
* To run in detached mode (in the background), use `docker-compose up -d --build`.
|
|
||||||
|
|
||||||
5. **Accessing Services:**
|
|
||||||
* **OpenWA API:** Typically `http://localhost:8080` (or the host port you mapped).
|
|
||||||
* **WhatsApp Router:** `http://localhost:3001` (its webhook is at `http://localhost:3001/webhook`, but this is for OpenWA to call internally).
|
|
||||||
* **Chat UI:** `http://localhost:3002`.
|
|
||||||
|
|
||||||
6. **Initial OpenWA Setup:**
|
|
||||||
* After starting, OpenWA will likely require you to scan a QR code with your WhatsApp mobile app to link it. Check the logs of the `openwa` service for the QR code or instructions:
|
|
||||||
```bash
|
|
||||||
docker-compose logs openwa
|
|
||||||
```
|
|
||||||
* Session data for OpenWA is stored in a Docker volume named `openwa_data` to persist the session across restarts.
|
|
||||||
|
|
||||||
7. **Stopping the services:**
|
|
||||||
```bash
|
|
||||||
docker-compose down
|
|
||||||
```
|
|
||||||
* To remove volumes (like `openwa_data`, which will clear the session), use `docker-compose down -v`.
|
|
||||||
|
|
||||||
## Project Structure
|
|
||||||
|
|
||||||
* `docker-compose.yml`: Defines and configures all the services.
|
|
||||||
* `chat-ui/`: Contains the Dockerfile and source code for the Chat UI service.
|
|
||||||
* `Dockerfile`: Instructions to build the Chat UI Docker image.
|
|
||||||
* `server.js`: Placeholder Node.js/Express application.
|
|
||||||
* `package.json`: Node.js project manifest.
|
|
||||||
* `whatsapp-router/`: Contains the Dockerfile and source code for the WhatsApp Router service.
|
|
||||||
* `Dockerfile`: Instructions to build the WhatsApp Router Docker image.
|
|
||||||
* `router.js`: Placeholder Node.js/Express application with a webhook.
|
|
||||||
* `package.json`: Node.js project manifest.
|
|
||||||
* `.gitignore`: Specifies intentionally untracked files that Git should ignore.
|
|
||||||
* `README.md`: This file.
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
# Use an official Node.js runtime as a parent image
|
|
||||||
FROM node:18-slim
|
|
||||||
|
|
||||||
# Set the working directory in the container
|
|
||||||
WORKDIR /usr/src/app
|
|
||||||
|
|
||||||
# Copy package.json and package-lock.json (or yarn.lock)
|
|
||||||
COPY package*.json ./
|
|
||||||
|
|
||||||
# Install application dependencies
|
|
||||||
RUN npm install
|
|
||||||
|
|
||||||
# Bundle app source
|
|
||||||
COPY . .
|
|
||||||
|
|
||||||
# Expose the port the app runs on
|
|
||||||
EXPOSE 3000
|
|
||||||
|
|
||||||
# Define the command to run the app
|
|
||||||
CMD [ "node", "server.js" ]
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "chat-ui",
|
|
||||||
"version": "1.0.0",
|
|
||||||
"description": "Chat UI for LLM Agent",
|
|
||||||
"main": "server.js",
|
|
||||||
"scripts": {
|
|
||||||
"start": "node server.js"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"express": "^4.17.1"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
const express = require('express');
|
|
||||||
const app = express();
|
|
||||||
const PORT = process.env.PORT || 3000;
|
|
||||||
|
|
||||||
app.get('/', (req, res) => {
|
|
||||||
res.send('Chat UI is running!');
|
|
||||||
});
|
|
||||||
|
|
||||||
app.listen(PORT, () => {
|
|
||||||
console.log(`Chat UI listening on port ${PORT}`);
|
|
||||||
});
|
|
||||||
@@ -1,67 +0,0 @@
|
|||||||
version: '3.8'
|
|
||||||
|
|
||||||
services:
|
|
||||||
openwa:
|
|
||||||
# IMPORTANT: Replace with your specific OpenWA image if different.
|
|
||||||
# This is a commonly used one, but your setup might require another.
|
|
||||||
image: devlikeapro/open-wa-api:latest
|
|
||||||
ports:
|
|
||||||
# Default port for OpenWA API is often 8080. Adjust if your image uses a different one.
|
|
||||||
- "8080:8080"
|
|
||||||
# Port for the webhook if OpenWA serves it directly.
|
|
||||||
# This might also be configured via environment variables for OpenWA.
|
|
||||||
- "3000:3000" # Assuming OpenWA's webhook might be on 3000, adjust as needed
|
|
||||||
environment:
|
|
||||||
# Add any necessary environment variables for OpenWA here
|
|
||||||
# For example:
|
|
||||||
# - WEBHOOK_URL=http://whatsapp-router:3001/webhook
|
|
||||||
# The actual variable names will depend on the OpenWA image being used.
|
|
||||||
- SERVER_PORT=8080 # Example, may not be needed if image defaults correctly
|
|
||||||
volumes:
|
|
||||||
# Persist session data for OpenWA to avoid re-scanning QR code on restart
|
|
||||||
- openwa_data:/app/session
|
|
||||||
# networks:
|
|
||||||
# - conversation_net
|
|
||||||
|
|
||||||
chat-ui:
|
|
||||||
build:
|
|
||||||
context: ./chat-ui
|
|
||||||
dockerfile: Dockerfile
|
|
||||||
ports:
|
|
||||||
- "3002:3000" # Expose Chat UI on host port 3002, container port 3000
|
|
||||||
environment:
|
|
||||||
# Example: Endpoint for the LLM agent
|
|
||||||
# - LLM_AGENT_URL=http://your-llm-agent-service/api
|
|
||||||
- NODE_ENV=development
|
|
||||||
# depends_on:
|
|
||||||
# - openwa # If Chat UI needs to directly interact with OpenWA
|
|
||||||
# networks:
|
|
||||||
# - conversation_net
|
|
||||||
|
|
||||||
whatsapp-router:
|
|
||||||
build:
|
|
||||||
context: ./whatsapp-router
|
|
||||||
dockerfile: Dockerfile
|
|
||||||
ports:
|
|
||||||
- "3001:3001" # Expose WhatsApp Router on host port 3001, container port 3001
|
|
||||||
environment:
|
|
||||||
# URL for OpenWA API
|
|
||||||
- OPENWA_API_URL=http://openwa:8080
|
|
||||||
# URL where OpenWA should send webhook events
|
|
||||||
# This should match what OpenWA is configured to call
|
|
||||||
- OPENWA_WEBHOOK_TARGET=http://whatsapp-router:3001/webhook
|
|
||||||
# Example: Endpoint for the LLM agent (if router talks to it)
|
|
||||||
# - LLM_AGENT_URL=http://your-llm-agent-service/api
|
|
||||||
- NODE_ENV=development
|
|
||||||
depends_on:
|
|
||||||
- openwa # Router needs OpenWA to be up
|
|
||||||
# networks:
|
|
||||||
# - conversation_net
|
|
||||||
|
|
||||||
volumes:
|
|
||||||
openwa_data: # Named volume for OpenWA session data
|
|
||||||
|
|
||||||
# Optional: Define a shared network
|
|
||||||
# networks:
|
|
||||||
# conversation_net:
|
|
||||||
# driver: bridge
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
# Use an official Node.js runtime as a parent image
|
|
||||||
FROM node:18-slim
|
|
||||||
|
|
||||||
# Set the working directory in the container
|
|
||||||
WORKDIR /usr/src/app
|
|
||||||
|
|
||||||
# Copy package.json and package-lock.json (or yarn.lock)
|
|
||||||
COPY package*.json ./
|
|
||||||
|
|
||||||
# Install application dependencies
|
|
||||||
RUN npm install
|
|
||||||
|
|
||||||
# Bundle app source
|
|
||||||
COPY . .
|
|
||||||
|
|
||||||
# Expose the port the app runs on (if it has an HTTP server for internal checks, though not strictly necessary for a router)
|
|
||||||
EXPOSE 3001
|
|
||||||
|
|
||||||
# Define the command to run the app
|
|
||||||
CMD [ "node", "router.js" ]
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "whatsapp-router",
|
|
||||||
"version": "1.0.0",
|
|
||||||
"description": "WhatsApp Router for OpenWA and LLM Agent",
|
|
||||||
"main": "router.js",
|
|
||||||
"scripts": {
|
|
||||||
"start": "node router.js"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"express": "^4.17.1"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
const express = require('express');
|
|
||||||
const app = express();
|
|
||||||
const PORT = process.env.PORT || 3001;
|
|
||||||
|
|
||||||
app.use(express.json());
|
|
||||||
|
|
||||||
app.post('/webhook', (req, res) => {
|
|
||||||
console.log('Received webhook event:', req.body);
|
|
||||||
// Logic to process OpenWA event and interact with LLM agent will go here
|
|
||||||
res.status(200).send('Event received');
|
|
||||||
});
|
|
||||||
|
|
||||||
app.listen(PORT, () => {
|
|
||||||
console.log(`WhatsApp Router listening on port ${PORT}`);
|
|
||||||
console.log('Webhook endpoint available at /webhook');
|
|
||||||
});
|
|
||||||
Reference in New Issue
Block a user