From 1790149986686dce173a39adae105a998b9c5020 Mon Sep 17 00:00:00 2001 From: yiling Date: Sun, 14 Jun 2026 11:04:04 +0800 Subject: [PATCH] docs(readme): improve remote deployment and temporal execution instructions --- README.md | 66 +++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 42 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 31972d59..c3014c36 100644 --- a/README.md +++ b/README.md @@ -41,15 +41,16 @@ The easiest way to run Shumai is using Docker Compose. You do not need to clone ```bash curl -o docker-compose.yaml https://raw.githubusercontent.com/shumaiOne/shumai/main/docker-compose/local/docker-compose.yaml ``` -2. Start the services: +2. Configure environment variables (if deploying remotely): + If you are deploying Shumai to a remote server (e.g., AWS ECS, EC2, VPS), you must edit `docker-compose.yaml` under `shumai -> environment` to set: + - `AWS_ENDPOINT_URL_S3` to your server's public IP or domain name (e.g., `http://43.153.213.233:3000`). + - `BETTER_AUTH_URL` to your server's public IP or domain name (e.g., `http://43.153.213.233:3000`). +3. Start the services: ```bash docker compose up -d ``` -3. Access the application in your browser at: - ``` - http://localhost:3000 - ``` -4. Stop and remove the services: +4. Access the application in your browser at `http://localhost:3000` (or `http://:3000` for remote deployments). +5. Stop and remove the services: ```bash docker compose down ``` @@ -94,11 +95,15 @@ Create a `.env` file in this folder and add the following configuration (which a ```env DATABASE_URL=postgresql://shumai:shumai_password@localhost:5432/shumai_db?schema=public -BETTER_AUTH_SECRET=ySxs7DxzHDGBbeeHNPEwBuspYwipBqz5Gk5XdBjNhWw= +BETTER_AUTH_SECRET=ySxs7DxzHDZBbeeHNPEwBuspYwipBqz5Gk5XdBjNhWw= BETTER_AUTH_URL=http://localhost:3000 STORAGE_BACKEND=local +AWS_ENDPOINT_URL_S3=http://localhost:3000 ``` +> [!NOTE] +> If you are deploying on a remote server, make sure to change `BETTER_AUTH_URL` and `AWS_ENDPOINT_URL_S3` from `http://localhost:3000` to your server's public IP address or domain name (e.g., `http://43.153.213.233:3000`). + #### Step 4: Run Shumai Start the application from your configuration folder: @@ -142,39 +147,52 @@ For production environments or workloads with heavy media processing and AI agen By setting the environment variable `WORKFLOW_EXECUTOR=temporal`, the main Shumai application will delegate background workflows to a Temporal cluster instead of using the local polling-based engine. This allows you to run independent worker processes (`shumai-agent` and `shumai-transcode`) on separate specialized machines (e.g., transcoding workers on GPU-accelerated instances, and agents on sandboxed environments). -### 1. Configure the environment +> [!IMPORTANT] +> **Storage Requirement**: Because the main Shumai application and the background workers run on different machines in a distributed setup, **you must use S3-compatible storage** (e.g., AWS S3, Cloudflare R2, MinIO). Local storage (`STORAGE_BACKEND=local`) will not work because the workers and the main application do not share a common local filesystem. -Add the following variables to your `.env` configuration on all machines: +### 1. Set up the Core Stack -```env -WORKFLOW_EXECUTOR=temporal -TEMPORAL_ADDRESS=localhost:7233 -``` +Spin up the database, Temporal server, and the main Shumai web application on your primary host machine using Docker Compose: -### 2. Set up the stack - -You can spin up the main application, database, and Temporal services using Docker Compose: - -1. Create a `docker-compose.yaml` file by downloading the configuration: +1. Download the Temporal-enabled `docker-compose.yaml` file: ```bash curl -o docker-compose.yaml https://raw.githubusercontent.com/shumaiOne/shumai/main/docker-compose/temporal/docker-compose.yaml ``` -2. Start the services: +2. Configure the environment variables in `docker-compose.yaml`: + - Set the S3 storage environment variables (`S3_ENDPOINT_URL`, `S3_REGION`, `BUCKET_NAME`, etc.). + - If deploying to a remote host (e.g., AWS ECS, EC2, VPS), update `AWS_ENDPOINT_URL_S3` and `BETTER_AUTH_URL` under the `shumai` service to your server's public IP address or domain name (e.g., `http://43.153.213.233:3000`). + - Note: The `TEMPORAL_ADDRESS` environment variable for the main Shumai application is pre-configured as `temporal:7233` (referencing the Temporal container within the same Docker network) and does not need to be changed. +3. Start the services: ```bash docker compose up -d ``` - This exposes the Shumai Web UI at `http://localhost:3000` and the Temporal dashboard at `http://localhost:8080`. + This exposes the Shumai Web UI at `http://:3000`, the database at port `5432`, the Temporal gRPC service at port `7233`, and the Temporal dashboard at `http://:8080`. Ensure that port `7233` is exposed and accessible by your background worker machines. -### 3. Run the background workers +### 2. Run the Background Workers -When running in Temporal mode, the main Shumai application only submits tasks to the Temporal queue. To process these tasks, you must run at least one agent worker and one transcoding worker: +When running in Temporal mode, the main Shumai application only submits tasks to the Temporal queue. To process these tasks, you must run at least one agent worker and one transcoding worker on their respective machines. + +Configure a `.env` file on each worker machine. It must contain the following variables: + +```env +DATABASE_URL=postgresql://shumai:shumai_password@:5432/shumai_db?schema=public +TEMPORAL_ADDRESS=:7233 +STORAGE_BACKEND=s3 +AWS_ENDPOINT_URL_S3=http://:3000 # Or your public S3/R2 endpoint URL +S3_REGION=us-east-1 +S3_BUCKET=shumai +S3_ACCESS_KEY_ID=your-access-key-id +S3_SECRET_ACCESS_KEY=your-secret-access-key +``` + +Run the workers: - **Transcoding Worker**: Install `@shumai-one/shumai-transcode` and run it on a machine with sufficient transcoding resources: ```bash npm install -g @shumai-one/shumai-transcode - # Run worker with correct .env containing DATABASE_URL and TEMPORAL_ADDRESS + # Run worker with the configured .env shumai-transcode ``` @@ -182,6 +200,6 @@ When running in Temporal mode, the main Shumai application only submits tasks to Install `@shumai-one/shumai-agent` and run it on a machine configured for AI tasks (with access to sandbox environments and `GEMINI_API_KEY`): ```bash npm install -g @shumai-one/shumai-agent - # Run worker with correct .env containing DATABASE_URL and TEMPORAL_ADDRESS + # Run worker with the configured .env (must include GEMINI_API_KEY) shumai-agent ```