feat: add Docker support for cross-platform deployment

This commit is contained in:
Yijia-Xiao 2026-04-04 08:14:01 +00:00
parent 4f965bf46a
commit 10c136f49c
No known key found for this signature in database
4 changed files with 89 additions and 0 deletions

15
.dockerignore Normal file
View File

@ -0,0 +1,15 @@
.git
.venv
.env
.claude
.idea
.vscode
.DS_Store
__pycache__
*.egg-info
build
dist
results
eval_results
Dockerfile
docker-compose.yml

27
Dockerfile Normal file
View File

@ -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"]

View File

@ -118,6 +118,19 @@ Install the package and its dependencies:
pip install . 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 ### Required APIs
TradingAgents supports multiple LLM providers. Set the API key for your chosen provider: TradingAgents supports multiple LLM providers. Set the API key for your chosen provider:

34
docker-compose.yml Normal file
View File

@ -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: