Skip to content

TradingAgents: Multi-Agents LLM Financial Trading Framework

feat: add Docker support for cross-platform deployment

Yijia-Xiao10c136f49c82
diff --git a/.dockerignore b/.dockerignore
new file mode 100644
index 000000000..cac710188
--- /dev/null
+++ b/.dockerignore
@@ -0,0 +1,15 @@
+.git
+.venv
+.env
+.claude
+.idea
+.vscode
+.DS_Store
+__pycache__
+*.egg-info
+build
+dist
+results
+eval_results
+Dockerfile
+docker-compose.yml
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 000000000..940609d35
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,27 @@
+FROM python:3.12-slim AS builder
+
+ENV PYTHONDONTWRITEBYTECODE=1 \
+ PIP_DISABLE_PIP_VERSION_CHECK=1
+
+RUN python -m venv /opt/venv
+ENV PATH="/opt/venv/bin:$PATH"
+
+WORKDIR /build
+COPY . .
+RUN pip install --no-cache-dir .
+
+FROM python:3.12-slim
+
+ENV PYTHONDONTWRITEBYTECODE=1 \
+ PYTHONUNBUFFERED=1
+
+COPY --from=builder /opt/venv /opt/venv
+ENV PATH="/opt/venv/bin:$PATH"
+
+RUN useradd --create-home appuser
+USER appuser
+WORKDIR /home/appuser/app
+
+COPY --from=builder --chown=appuser:appuser /build .
+
+ENTRYPOINT ["tradingagents"]
diff --git a/README.md b/README.md
index 4cfeb4e52..9a92bff99 100644
--- a/README.md
+++ b/README.md
@@ -118,6 +118,19 @@ Install the package and its dependencies:
pip install .
```
+### Docker
+
+Alternatively, run with Docker:
+```bash
+cp .env.example .env # add your API keys
+docker compose run --rm tradingagents
+```
+
+For local models with Ollama:
+```bash
+docker compose --profile ollama run --rm tradingagents-ollama
+```
+
### Required APIs
TradingAgents supports multiple LLM providers. Set the API key for your chosen provider:
diff --git a/docker-compose.yml b/docker-compose.yml
new file mode 100644
index 000000000..3a5d4e299
--- /dev/null
+++ b/docker-compose.yml
@@ -0,0 +1,34 @@
+services:
+ tradingagents:
+ build: .
+ env_file:
+ - .env
+ volumes:
+ - ./results:/home/appuser/app/results
+ tty: true
+ stdin_open: true
+
+ ollama:
+ image: ollama/ollama:latest
+ volumes:
+ - ollama_data:/root/.ollama
+ profiles:
+ - ollama
+
+ tradingagents-ollama:
+ build: .
+ env_file:
+ - .env
+ environment:
+ - LLM_PROVIDER=ollama
+ volumes:
+ - ./results:/home/appuser/app/results
+ depends_on:
+ - ollama
+ tty: true
+ stdin_open: true
+ profiles:
+ - ollama
+
+volumes:
+ ollama_data: