mirror of
https://github.com/basicmachines-co/basic-memory
synced 2026-06-21 13:47:35 +00:00
fix: configure Docker to use mounted volume for basic-memory data
- Add docker-init.sh script to initialize config.json pointing to /app/data - Update Dockerfile to use initialization script as entrypoint - Update docker-compose.yml comments to reflect automatic configuration - Ensures mounted knowledge files in /app/data are properly indexed Fixes issue where .basic-memory/config.json wasn't configured to use the mounted directory, causing files in /app/data to not get indexed. Co-authored-by: Paul Hernandez <phernandez@users.noreply.github.com>
This commit is contained in:
+6
-1
@@ -17,6 +17,10 @@ RUN uv sync --locked
|
||||
# Create data directory
|
||||
RUN mkdir -p /app/data
|
||||
|
||||
# Copy and setup initialization script
|
||||
COPY docker-init.sh /app/docker-init.sh
|
||||
RUN chmod +x /app/docker-init.sh
|
||||
|
||||
# Set default data directory and add venv to PATH
|
||||
ENV BASIC_MEMORY_HOME=/app/data \
|
||||
PATH="/app/.venv/bin:$PATH"
|
||||
@@ -28,5 +32,6 @@ EXPOSE 8000
|
||||
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
|
||||
CMD basic-memory --version || exit 1
|
||||
|
||||
# Use the basic-memory entrypoint to run the MCP server with default SSE transport
|
||||
# Use initialization script as entrypoint with the basic-memory command
|
||||
ENTRYPOINT ["/app/docker-init.sh"]
|
||||
CMD ["basic-memory", "mcp", "--transport", "sse", "--host", "0.0.0.0", "--port", "8000"]
|
||||
+2
-2
@@ -27,8 +27,8 @@ services:
|
||||
# - ./work-notes:/app/data/work:rw
|
||||
# - ./personal-notes:/app/data/personal:rw
|
||||
|
||||
# You can edit the project config manually in the mounted config volume
|
||||
# The default project will be configured to use /app/data
|
||||
# Configuration is automatically initialized to use the mounted /app/data directory
|
||||
# You can edit the project config manually in the mounted config volume if needed
|
||||
environment:
|
||||
# Project configuration
|
||||
- BASIC_MEMORY_DEFAULT_PROJECT=main
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
# Initialize Basic Memory configuration for Docker
|
||||
CONFIG_DIR="/root/.basic-memory"
|
||||
CONFIG_FILE="$CONFIG_DIR/config.json"
|
||||
DATA_DIR="/app/data"
|
||||
|
||||
echo "Initializing Basic Memory Docker configuration..."
|
||||
|
||||
# Create config directory if it doesn't exist
|
||||
mkdir -p "$CONFIG_DIR"
|
||||
|
||||
# Create config.json if it doesn't exist or if it doesn't point to the correct data directory
|
||||
if [ ! -f "$CONFIG_FILE" ] || ! grep -q '"main".*"/app/data"' "$CONFIG_FILE" 2>/dev/null; then
|
||||
echo "Creating config.json pointing to mounted volume at $DATA_DIR"
|
||||
cat > "$CONFIG_FILE" << EOF
|
||||
{
|
||||
"projects": {
|
||||
"main": "$DATA_DIR"
|
||||
},
|
||||
"default_project": "main",
|
||||
"env": "user",
|
||||
"log_level": "INFO",
|
||||
"sync_changes": true,
|
||||
"sync_delay": 1000,
|
||||
"update_permalinks_on_move": false
|
||||
}
|
||||
EOF
|
||||
else
|
||||
echo "Config file already exists and points to correct data directory"
|
||||
fi
|
||||
|
||||
# Ensure data directory exists
|
||||
mkdir -p "$DATA_DIR"
|
||||
|
||||
echo "Configuration initialized successfully"
|
||||
echo "Config file contents:"
|
||||
cat "$CONFIG_FILE"
|
||||
|
||||
# Execute the original command
|
||||
exec "$@"
|
||||
Reference in New Issue
Block a user