From ed7cca47fa408c63ecc09f45d8383123104adff2 Mon Sep 17 00:00:00 2001 From: Charles Vien Date: Mon, 23 Dec 2024 18:01:56 -0800 Subject: [PATCH] Add Docker workflow for publishing image and system setup --- .github/workflows/docker-publish.yml | 49 ++++++++++++++++++++++++++++ README.md | 33 +++++++++++++++++++ docker-compose.yml | 8 ++--- 3 files changed, 84 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/docker-publish.yml diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml new file mode 100644 index 00000000..60f85404 --- /dev/null +++ b/.github/workflows/docker-publish.yml @@ -0,0 +1,49 @@ +name: Docker + +on: + push: + branches: [ "main" ] + tags: [ 'v*.*.*' ] + pull_request: + branches: [ "main" ] + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + build: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Log in to the Container registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file diff --git a/README.md b/README.md index 55498190..b27238ae 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,17 @@ git clone https://github.com/virattt/ai-hedge-fund.git cd ai-hedge-fund ``` +### System Requirements +- CPU: Any modern CPU (last 5 years) +- RAM: 2GB minimum, 4GB recommended +- Storage: 1GB free space +- Internet: Stable connection required +- No GPU required + +The system is lightweight as it primarily manages workflows between APIs (OpenAI and financial data) without running any local AI models. + +### Option 1: Local Setup + 1. Install Poetry (if not already installed): ```bash curl -sSL https://install.python-poetry.org | python3 - @@ -64,6 +75,28 @@ export OPENAI_API_KEY='your-api-key-here' # Get a key from https://platform.open export FINANCIAL_DATASETS_API_KEY='your-api-key-here' # Get a key from https://financialdatasets.ai/ ``` +### Option 2: Docker Setup + +You can either build the image locally or use our official image from GitHub Container Registry: + +#### Using the Official Image + +1. Create and configure your `.env` file as explained above. + +2. Pull and run the official image using docker compose: +```bash +# Run the trading agent +docker compose run agent --ticker AAPL + +# Run the backtester +docker compose run backtester --ticker AAPL + +# Run with custom parameters +docker compose run agent --ticker AAPL --start-date 2024-01-01 --end-date 2024-03-01 --show-reasoning +``` + +The Docker setup uses a lightweight Python 3.9 base image and installs only the required dependencies. + ## Usage ### Running the Hedge Fund diff --git a/docker-compose.yml b/docker-compose.yml index e1022ad5..3aa3a208 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,9 +2,7 @@ version: '3.8' services: agent: - build: - context: . - dockerfile: Dockerfile + image: ghcr.io/virattt/ai-hedge-fund:main env_file: .env volumes: - .:/app @@ -14,9 +12,7 @@ services: - ai-hedge-fund backtester: - build: - context: . - dockerfile: Dockerfile + image: ghcr.io/virattt/ai-hedge-fund:main env_file: .env volumes: - .:/app