From ceb1d82bf6eaa3f77feac495b4e8b92b4a3ae18b Mon Sep 17 00:00:00 2001 From: Debanjum Date: Sat, 31 May 2025 21:39:38 -0700 Subject: [PATCH] Create khoj computer via cloud build. Add computer to docker-compose.yml --- .github/workflows/dockerize.yml | 29 +++++++++++++++++++++++++++++ docker-compose.yml | 11 +++++++++++ 2 files changed, 40 insertions(+) diff --git a/.github/workflows/dockerize.yml b/.github/workflows/dockerize.yml index 1321982d..901ac137 100644 --- a/.github/workflows/dockerize.yml +++ b/.github/workflows/dockerize.yml @@ -12,6 +12,7 @@ on: - pyproject.toml - Dockerfile - prod.Dockerfile + - computer.Dockerfile - docker-compose.yml - .github/workflows/dockerize.yml workflow_dispatch: @@ -27,6 +28,10 @@ on: description: 'Build Khoj cloud docker image' type: boolean default: true + khoj-computer: + description: 'Build computer for Khoj' + type: boolean + default: true env: # Tag Image with tag name on release @@ -115,6 +120,21 @@ jobs: org.opencontainers.image.description=Khoj AI Cloud - Your second brain powered by LLMs and Neural Search org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }} + - name: 📦️️💻 Build and Push Computer for Khoj + uses: docker/build-push-action@v4 + if: github.event_name == 'workflow_dispatch' && github.event.inputs.khoj-computer == 'true' + with: + context: . + file: computer.Dockerfile + push: true + tags: | + ghcr.io/${{ github.repository }}-computer:${{ env.DOCKER_IMAGE_TAG }}-${{ matrix.platform == 'linux/amd64' && 'amd64' || 'arm64' }} + cache-from: type=gha,scope=computer-${{ matrix.platform }} + cache-to: type=gha,mode=max,scope=computer-${{ matrix.platform }} + labels: | + org.opencontainers.image.description=Khoj AI Computer - A computer for your second brain to operate + org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }} + manifest: needs: build runs-on: ubuntu-latest @@ -147,3 +167,12 @@ jobs: -t ghcr.io/${{ github.repository }}-cloud:${{ github.ref_type == 'tag' && 'latest' || env.DOCKER_IMAGE_TAG }} \ ghcr.io/${{ github.repository }}-cloud:${{ env.DOCKER_IMAGE_TAG }}-amd64 \ ghcr.io/${{ github.repository }}-cloud:${{ env.DOCKER_IMAGE_TAG }}-arm64 + + - name: Create and Push Computer Manifest + if: github.event.inputs.khoj-computer == 'true' + run: | + docker buildx imagetools create \ + -t ghcr.io/${{ github.repository }}-computer:${{ env.DOCKER_IMAGE_TAG }} \ + -t ghcr.io/${{ github.repository }}-computer:${{ github.ref_type == 'tag' && 'latest' || env.DOCKER_IMAGE_TAG }} \ + ghcr.io/${{ github.repository }}-computer:${{ env.DOCKER_IMAGE_TAG }}-amd64 \ + ghcr.io/${{ github.repository }}-computer:${{ env.DOCKER_IMAGE_TAG }}-arm64 diff --git a/docker-compose.yml b/docker-compose.yml index a6c08add..934ee9ac 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -25,6 +25,14 @@ services: - khoj_search:/etc/searxng environment: - SEARXNG_BASE_URL=http://localhost:8080/ + # Creates Computer for Khoj to use. + # Set KHOJ_OPERATOR_ENABLED=True in the server service environment variable to enable. + computer: + image: ghcr.io/khoj-ai/computer:latest + ports: + - "5900:5900" + volumes: + - khoj_computer:/home/operator server: depends_on: database: @@ -75,6 +83,8 @@ services: # - GEMINI_API_KEY=your_gemini_api_key # - ANTHROPIC_API_KEY=your_anthropic_api_key # + # Uncomment line below to enable Khoj to use its computer. + # - KHOJ_OPERATOR_ENABLED=True # Uncomment appropriate lines below to enable web results with Khoj # Ensure you set your provider specific API keys. # --- @@ -112,3 +122,4 @@ volumes: khoj_db: khoj_models: khoj_search: + khoj_computer: