-
Notifications
You must be signed in to change notification settings - Fork 2.3k
feat: add docker-compose deployment and config for local embeddings #1164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
vinbyte
wants to merge
6
commits into
rohitg00:main
Choose a base branch
from
vinbyte:feat/docker-compose-deploy
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
6f068b0
feat: add docker-compose deployment and config for local embeddings
vinbyte 694c7db
Update deploy/docker-compose/entrypoint.sh
vinbyte 8ac1ea3
Update src/providers/embedding/local.ts
vinbyte e88e9e9
fix: use npm install instead of npm ci in docker build
vinbyte c7a9347
fix(deploy): restore missing secret output in docker-compose entrypoi…
vinbyte 9bc9b7f
fix(deploy): bind docker compose ports to 127.0.0.1 for reverse proxy…
vinbyte File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| # ========================================== | ||
| # AgentMemory Configuration | ||
| # ========================================== | ||
|
|
||
| # ------------------------------------------ | ||
| # 1. LLM Provider (Deepseek Flash V4 / openrouter) | ||
| # ------------------------------------------ | ||
| # To use Deepseek, you can use OpenRouter or direct DeepSeek API (OpenAI compatible) | ||
| # Uncomment one of the following approaches: | ||
|
|
||
| # Approach A: OpenRouter (Recommended for Deepseek) | ||
| OPENROUTER_API_KEY=your_openrouter_api_key_here | ||
| OPENROUTER_MODEL=deepseek/deepseek-chat | ||
|
|
||
| # Approach B: Direct DeepSeek API | ||
| # OPENAI_API_KEY=your_deepseek_api_key_here | ||
| # OPENAI_BASE_URL=https://api.deepseek.com | ||
| # OPENAI_MODEL=deepseek-chat | ||
|
|
||
| # ------------------------------------------ | ||
| # 2. Embeddings Configuration (CPU-only Local) | ||
| # ------------------------------------------ | ||
| # Set embedding provider to local | ||
| EMBEDDING_PROVIDER=local | ||
|
|
||
| # Default model is Xenova/all-MiniLM-L6-v2. If you change it, | ||
| # make sure you update the dimensions to match your model! | ||
| # NOTE: The custom model support requires building from the latest modified source. | ||
| LOCAL_EMBEDDING_MODEL=Xenova/all-MiniLM-L6-v2 | ||
| LOCAL_EMBEDDING_DIMENSIONS=384 | ||
|
|
||
| # ------------------------------------------ | ||
| # 3. AgentMemory Features | ||
| # ------------------------------------------ | ||
| # Run LLM compression on every observation batch (Warning: uses LLM tokens) | ||
| AGENTMEMORY_AUTO_COMPRESS=false | ||
|
|
||
| # Inject recalled memories back into agent prompts | ||
| AGENTMEMORY_INJECT_CONTEXT=false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| # Build stage | ||
| FROM node:22-slim AS builder | ||
| WORKDIR /app | ||
| COPY package*.json ./ | ||
| RUN npm install | ||
| COPY . . | ||
| RUN npm run build | ||
| RUN npm prune --production | ||
|
|
||
| # Final stage | ||
| FROM iiidev/iii:0.11.2 AS iii-image | ||
|
|
||
| FROM node:22-slim | ||
| WORKDIR /opt/agentmemory | ||
| RUN apt-get update \ | ||
| && apt-get install -y --no-install-recommends openssl ca-certificates tini gosu curl \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
|
|
||
| COPY --from=iii-image /app/iii /usr/local/bin/iii | ||
| COPY --from=builder /app/package*.json ./ | ||
| COPY --from=builder /app/node_modules ./node_modules | ||
| COPY --from=builder /app/dist ./dist | ||
|
|
||
| # Symlink so `agentmemory` works globally | ||
| RUN ln -s /opt/agentmemory/dist/cli.mjs /usr/local/bin/agentmemory \ | ||
| && chmod +x /opt/agentmemory/dist/cli.mjs | ||
|
|
||
| ENV AGENTMEMORY_III_VERSION=0.11.2 \ | ||
| TINI_SUBREAPER=1 | ||
|
|
||
| COPY deploy/docker-compose/entrypoint.sh /usr/local/bin/agentmemory-entrypoint.sh | ||
| RUN chmod 0755 /usr/local/bin/agentmemory-entrypoint.sh | ||
|
|
||
| EXPOSE 3111 | ||
|
|
||
| HEALTHCHECK --interval=30s --timeout=5s --start-period=30s --retries=3 \ | ||
| CMD curl -fsS http://127.0.0.1:3111/agentmemory/livez || exit 1 | ||
|
|
||
| ENTRYPOINT ["/usr/bin/tini", "--", "/usr/local/bin/agentmemory-entrypoint.sh"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| services: | ||
| agentmemory: | ||
| build: | ||
| context: ../.. | ||
| dockerfile: deploy/docker-compose/Dockerfile | ||
| restart: unless-stopped | ||
| env_file: | ||
| - .env | ||
| expose: | ||
| - "3111" | ||
| ports: | ||
| - "127.0.0.1:3111:3111" | ||
| - "127.0.0.1:3112:3112" | ||
| - "127.0.0.1:3113:3113" | ||
| volumes: | ||
| - agentmemory-data:/data | ||
| healthcheck: | ||
| test: ["CMD-SHELL", "curl -fsS http://127.0.0.1:3111/agentmemory/livez || exit 1"] | ||
| interval: 30s | ||
| timeout: 5s | ||
| start_period: 30s | ||
| retries: 3 | ||
| logging: | ||
| driver: json-file | ||
| options: | ||
| max-size: "10m" | ||
| max-file: "3" | ||
|
|
||
| volumes: | ||
| agentmemory-data: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| #!/bin/sh | ||
| # agentmemory first-boot entrypoint. | ||
| # | ||
| # Runs as root so it can: | ||
| # 1. Overwrite the iii-config.yaml with a deploy-tuned version that | ||
| # binds 0.0.0.0 and uses absolute /data paths. | ||
| # 2. chown the platform-mounted /data volume to the runtime user | ||
| # (managed platforms mount volumes root-owned 755 by default). | ||
| # 3. Generate the HMAC secret on first boot and persist it to | ||
| # /data/.hmac (chmod 600) so the secret survives restarts. | ||
| # | ||
| # Then it execs the agentmemory CLI under gosu as the unprivileged | ||
| # `node` user. | ||
|
|
||
| set -eu | ||
|
|
||
| DATA_DIR="${AGENTMEMORY_DATA_DIR:-/data}" | ||
| HMAC_FILE="${AGENTMEMORY_HMAC_FILE:-/data/.hmac}" | ||
| RUN_AS="node:node" | ||
| III_CONFIG="/opt/agentmemory/dist/iii-config.yaml" | ||
|
|
||
| mkdir -p "$DATA_DIR" | ||
| chown -R "$RUN_AS" "$DATA_DIR" | ||
|
|
||
| cat > "$III_CONFIG" <<'EOF' | ||
| workers: | ||
| - name: iii-http | ||
| config: | ||
| port: 3111 | ||
| host: 0.0.0.0 | ||
| default_timeout: 180000 | ||
| cors: | ||
| allowed_origins: | ||
| - "http://localhost:3111" | ||
| - "http://localhost:3113" | ||
| - "http://127.0.0.1:3111" | ||
| - "http://127.0.0.1:3113" | ||
| allowed_methods: [GET, POST, PUT, DELETE, OPTIONS] | ||
| - name: iii-state | ||
| config: | ||
| adapter: | ||
| name: kv | ||
| config: | ||
| store_method: file_based | ||
| file_path: /data/state_store.db | ||
| - name: iii-queue | ||
| config: | ||
| adapter: | ||
| name: builtin | ||
| - name: iii-pubsub | ||
| config: | ||
| adapter: | ||
| name: local | ||
| - name: iii-cron | ||
| config: | ||
| adapter: | ||
| name: kv | ||
| - name: iii-stream | ||
| config: | ||
| port: 3112 | ||
| host: 0.0.0.0 | ||
| adapter: | ||
| name: kv | ||
| config: | ||
| store_method: file_based | ||
| file_path: /data/stream_store | ||
| - name: iii-observability | ||
| config: | ||
| enabled: true | ||
| service_name: agentmemory | ||
| exporter: memory | ||
| sampling_ratio: 1.0 | ||
| metrics_enabled: true | ||
| logs_enabled: true | ||
| logs_console_output: true | ||
| EOF | ||
| chown "$RUN_AS" "$III_CONFIG" | ||
|
|
||
| if [ ! -s "$HMAC_FILE" ]; then | ||
| SECRET="$(openssl rand -hex 32)" | ||
| umask 077 | ||
| printf '%s\n' "$SECRET" > "$HMAC_FILE" | ||
| chmod 600 "$HMAC_FILE" | ||
| chown "$RUN_AS" "$HMAC_FILE" | ||
| echo "================================================================" | ||
| echo "agentmemory: generated HMAC secret on first boot" | ||
| echo "AGENTMEMORY_SECRET=$SECRET" | ||
| echo "Copy this value now. It will not be printed again." | ||
| echo "Stored at: $HMAC_FILE (chmod 600)" | ||
| echo "To rotate: delete $HMAC_FILE on the persistent volume and restart." | ||
| echo "================================================================" | ||
| fi | ||
|
|
||
| AGENTMEMORY_SECRET="$(cat "$HMAC_FILE")" | ||
| export AGENTMEMORY_SECRET | ||
|
|
||
| exec gosu "$RUN_AS" agentmemory "$@" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.