Skip to content

BrainAPI is a knowledge graph–powered AI memory layer that transforms unstructured data into structured knowledge, enabling intelligent search, recommendations, and contextual memory for AI agents and applications.

fix(env): celery app broker switch + mongo config fix int

Christian51035e691e73
diff --git a/.github/workflows/tags.yaml b/.github/workflows/tags.yaml
index 18fa089..3646ff0 100644
--- a/.github/workflows/tags.yaml
+++ b/.github/workflows/tags.yaml
@@ -1,41 +1,87 @@
-name: release-on-tag
+name: Build and Push Container
on:
- push:
- tags:
- - "v*"
- branches:
- - main
+ push:
+ branches:
+ - main
jobs:
- build-and-release:
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v4
- with: { fetch-depth: 0 }
- - name: Get tag
- id: vars
- run: echo "TAG=${GITHUB_REF_NAME}" >> $GITHUB_OUTPUT
-
- - uses: actions/setup-node@v4
- with: { node-version: "20" }
- - run: npm ci && npm run build
-
- - uses: docker/setup-buildx-action@v3
- - uses: docker/login-action@v3
- with:
- registry: ghcr.io
- username: ${{ github.actor }}
- password: ${{ secrets.GITHUB_TOKEN }}
- - uses: docker/build-push-action@v6
- with:
- context: .
- push: true
- tags: |
- ghcr.io/${{ github.repository }}/web:${{ steps.vars.outputs.TAG }}
- ghcr.io/${{ github.repository }}/web:${{ github.sha }}
-
- - uses: softprops/action-gh-release@v2
- with:
- tag_name: ${{ steps.vars.outputs.TAG }}
- generate_release_notes: true
+ build-and-push:
+ runs-on: ubuntu-latest
+
+ steps:
+ - name: Checkout code
+ uses: actions/checkout@v4
+
+ - name: Set up Python
+ uses: actions/setup-python@v4
+ with:
+ python-version: "3.11"
+
+ - name: Install Poetry
+ uses: snok/install-poetry@v1
+ with:
+ version: 1.8.3
+ virtualenvs-create: true
+ virtualenvs-in-project: true
+
+ - name: Load cached venv
+ id: cached-poetry-dependencies
+ uses: actions/cache@v3
+ with:
+ path: .venv
+ key: venv-${{ runner.os }}-3.11-${{ hashFiles('**/poetry.lock') }}
+
+ - name: Install dependencies
+ if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
+ run: poetry install --no-root --sync
+
+ - name: Get version
+ id: version
+ run: echo "VERSION=$(poetry version -s)" >> $GITHUB_OUTPUT
+
+ - name: Set up Docker Buildx
+ uses: docker/setup-buildx-action@v3
+
+ - name: Log in to GitHub Container Registry
+ uses: docker/login-action@v3
+ with:
+ registry: ghcr.io
+ username: ${{ github.actor }}
+ password: ${{ secrets.GITHUB_TOKEN }}
+
+ - name: Extract metadata
+ id: meta
+ uses: docker/metadata-action@v5
+ with:
+ images: ghcr.io/lumen-labs/brainapi
+ tags: |
+ type=ref,event=branch
+ type=ref,event=pr
+ type=semver,pattern={{version}}
+ type=semver,pattern={{major}}.{{minor}}
+ type=raw,value=latest,enable={{is_default_branch}}
+
+ - name: Build and push Docker image
+ uses: docker/build-push-action@v5
+ with:
+ context: .
+ platforms: linux/amd64
+ push: true
+ tags: |
+ ghcr.io/lumen-labs/brainapi:v${{ steps.version.outputs.VERSION }}
+ ghcr.io/lumen-labs/brainapi:latest
+ build-args: |
+ BUILD_DATE=${{ github.event.head_commit.timestamp }}
+ BUILD_SHA=${{ github.sha }}
+ CACHE_BUST=${{ github.run_number }}
+ cache-from: type=gha
+ cache-to: type=gha,mode=max
+
+ - name: Create Git tag (only on main branch)
+ if: github.ref == 'refs/heads/main'
+ run: |
+ git config --local user.email "[email protected]"
+ git config --local user.name "GitHub Action"
+ git tag -a v${{ steps.version.outputs.VERSION }} -m "Release v${{ steps.version.outputs.VERSION }}"
+ git push origin v${{ steps.version.outputs.VERSION }}
diff --git a/Makefile b/Makefile
index 2368099..e706fea 100644
--- a/Makefile
+++ b/Makefile
@@ -97,5 +97,7 @@ container-release:
CACHE_BUST=$$(date +%s)
docker build --no-cache --build-arg BUILD_DATE="$$BUILD_DATE" --build-arg BUILD_SHA="$$BUILD_SHA" --build-arg CACHE_BUST="$$CACHE_BUST" --platform linux/amd64 -t ghcr.io/lumen-labs/brainapi:v$$VERSION ./
docker tag ghcr.io/lumen-labs/brainapi:v$$VERSION ghcr.io/lumen-labs/brainapi:latest
+ git tag -s v$$VERSION -m "Release v$$VERSION"
docker push ghcr.io/lumen-labs/brainapi:v$$VERSION
- docker push ghcr.io/lumen-labs/brainapi:latest
\ No newline at end of file
+ docker push ghcr.io/lumen-labs/brainapi:latest
+ git push origin v$$VERSION
\ No newline at end of file
diff --git a/src/config.py b/src/config.py
index 0282e62..73a9d93 100644
--- a/src/config.py
+++ b/src/config.py
@@ -103,7 +103,7 @@ class MongoConfig:
def __init__(self):
self.host = os.getenv("MONGO_HOST")
- self.port = int(os.getenv("MONGO_PORT"))
+ self.port = int(os.getenv("MONGO_PORT")) if os.getenv("MONGO_PORT") else None
self.username = os.getenv("MONGO_USERNAME")
self.password = os.getenv("MONGO_PASSWORD")
diff --git a/src/workers/app.py b/src/workers/app.py
index e35f54e..97fe21c 100644
--- a/src/workers/app.py
+++ b/src/workers/app.py
@@ -8,12 +8,21 @@ Modified By: the developer formerly known as Christian Nonis at <alch.infoemail@
-----
"""
+import os
from celery import Celery
ingestion_app = Celery(
"ingestion_app",
- broker="amqp://kalo:kalo@localhost:5672/",
- backend="rpc://",
+ broker=(
+ "amqp://kalo:kalo@localhost:5672/"
+ if os.getenv("CELERY_BACKEND") == "rabbitmq"
+ else "redis://localhost:6379/0"
+ ),
+ backend=(
+ "rpc://"
+ if os.getenv("CELERY_BACKEND") == "rabbitmq"
+ else "redis://localhost:6379/0"
+ ),
include=["src.workers.tasks.ingestion"],
)