Skip to content

Commit ae5231d

Browse files
committed
Add Docker workflow for publishing image and system setup
1 parent d14772c commit ae5231d

File tree

3 files changed

+84
-27
lines changed

3 files changed

+84
-27
lines changed

.github/workflows/docker-publish.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Docker
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
tags: [ 'v*.*.*' ]
7+
pull_request:
8+
branches: [ "main" ]
9+
10+
env:
11+
REGISTRY: ghcr.io
12+
IMAGE_NAME: ${{ github.repository }}
13+
14+
jobs:
15+
build:
16+
runs-on: ubuntu-latest
17+
permissions:
18+
contents: read
19+
packages: write
20+
21+
steps:
22+
- name: Checkout repository
23+
uses: actions/checkout@v4
24+
25+
- name: Log in to the Container registry
26+
uses: docker/login-action@v3
27+
with:
28+
registry: ${{ env.REGISTRY }}
29+
username: ${{ github.actor }}
30+
password: ${{ secrets.GITHUB_TOKEN }}
31+
32+
- name: Extract metadata (tags, labels) for Docker
33+
id: meta
34+
uses: docker/metadata-action@v5
35+
with:
36+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
37+
tags: |
38+
type=ref,event=branch
39+
type=ref,event=pr
40+
type=semver,pattern={{version}}
41+
type=semver,pattern={{major}}.{{minor}}
42+
43+
- name: Build and push Docker image
44+
uses: docker/build-push-action@v5
45+
with:
46+
context: .
47+
push: ${{ github.event_name != 'pull_request' }}
48+
tags: ${{ steps.meta.outputs.tags }}
49+
labels: ${{ steps.meta.outputs.labels }}

README.md

Lines changed: 33 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ By using this software, you agree to use it solely for learning purposes.
3232
- [Usage](#usage)
3333
- [Running the Hedge Fund](#running-the-hedge-fund)
3434
- [Running the Backtester](#running-the-backtester)
35-
- [Docker](#docker)
3635
- [Project Structure](#project-structure)
3736
- [Contributing](#contributing)
3837
- [License](#license)
@@ -45,6 +44,17 @@ git clone https://github.com/virattt/ai-hedge-fund.git
4544
cd ai-hedge-fund
4645
```
4746

47+
### System Requirements
48+
- CPU: Any modern CPU (last 5 years)
49+
- RAM: 2GB minimum, 4GB recommended
50+
- Storage: 1GB free space
51+
- Internet: Stable connection required
52+
- No GPU required
53+
54+
The system is lightweight as it primarily manages workflows between APIs (OpenAI and financial data) without running any local AI models.
55+
56+
### Option 1: Local Setup
57+
4858
1. Install Poetry (if not already installed):
4959
```bash
5060
curl -sSL https://install.python-poetry.org | python3 -
@@ -64,6 +74,28 @@ export OPENAI_API_KEY='your-api-key-here' # Get a key from https://platform.open
6474
export FINANCIAL_DATASETS_API_KEY='your-api-key-here' # Get a key from https://financialdatasets.ai/
6575
```
6676

77+
### Option 2: Docker Setup
78+
79+
You can either build the image locally or use our official image from GitHub Container Registry:
80+
81+
#### Using the Official Image
82+
83+
1. Create and configure your `.env` file as explained above.
84+
85+
2. Pull and run the official image using docker compose:
86+
```bash
87+
# Run the trading agent
88+
docker compose run agent --ticker AAPL
89+
90+
# Run the backtester
91+
docker compose run backtester --ticker AAPL
92+
93+
# Run with custom parameters
94+
docker compose run agent --ticker AAPL --start-date 2024-01-01 --end-date 2024-03-01 --show-reasoning
95+
```
96+
97+
The Docker setup uses a lightweight Python 3.9 base image and installs only the required dependencies.
98+
6799
## Usage
68100

69101
### Running the Hedge Fund
@@ -109,26 +141,6 @@ You can optionally specify the start and end dates to backtest over a specific t
109141
poetry run python src/backtester.py --ticker AAPL --start-date 2024-01-01 --end-date 2024-03-01
110142
```
111143

112-
## Docker
113-
114-
You can run the project easily using Docker Compose.
115-
116-
1. Run the agent with custom parameters:
117-
```bash
118-
docker compose run agent --ticker AAPL
119-
```
120-
121-
2. Run the backtester with custom parameters:
122-
```bash
123-
docker compose run backtester --ticker AAPL
124-
```
125-
126-
Note:
127-
- The `.env` file will be automatically loaded by Docker Compose
128-
- Use `docker-compose up` to run with default parameters defined in docker-compose.yml
129-
- Use `docker-compose run` to pass custom parameters - no need to specify the python command
130-
- All arguments after the service name are passed directly to the script
131-
132144
## Project Structure
133145
```
134146
ai-hedge-fund/

docker-compose.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ version: '3.8'
22

33
services:
44
agent:
5-
build:
6-
context: .
7-
dockerfile: Dockerfile
5+
image: ghcr.io/virattt/ai-hedge-fund:main
86
env_file: .env
97
volumes:
108
- .:/app
@@ -14,9 +12,7 @@ services:
1412
- ai-hedge-fund
1513

1614
backtester:
17-
build:
18-
context: .
19-
dockerfile: Dockerfile
15+
image: ghcr.io/virattt/ai-hedge-fund:main
2016
env_file: .env
2117
volumes:
2218
- .:/app

0 commit comments

Comments
 (0)