improvement(OpenMemory MCP): Improves Docker Compose commands (#2681)

Co-authored-by: Deshraj Yadav <deshrajdry@gmail.com>
This commit is contained in:
Saket Aryan
2025-05-14 13:44:08 +05:30
committed by GitHub
parent da59412150
commit a22287a3ba
10 changed files with 45 additions and 78 deletions

View File

@@ -19,17 +19,13 @@ git clone https://github.com/mem0ai/mem0.git
cd mem0/openmemory cd mem0/openmemory
# Create the backend .env file with your OpenAI key # Create the backend .env file with your OpenAI key
pushd api && echo "OPENAI_API_KEY=your_key_here" > .env && popd make env
# Build the Docker images # Build the Docker images
make build make build
# Start all services (API server, vector database, and MCP server components) # Start all services (API server, vector database, and MCP server components)
make up make up
# Start the frontend
cp ui/.env.example ui/.env
make ui
``` ```
You can configure the MCP client using the following command (replace username with your username): You can configure the MCP client using the following command (replace username with your username):
@@ -44,4 +40,4 @@ Once set up, OpenMemory runs locally on your machine, ensuring all your AI memor
### Getting Started Today ### Getting Started Today
- Github Repository: https://github.com/mem0ai/mem0/openmemory - Github Repository: https://github.com/mem0ai/mem0/openmemory

View File

@@ -1,4 +1,4 @@
.PHONY: help up down logs shell migrate test test-clean env ui-install ui-start ui-dev .PHONY: help up down logs shell migrate test test-clean env ui-install ui-start ui-dev ui-build ui-dev-start
NEXT_PUBLIC_USER_ID=$(USER) NEXT_PUBLIC_USER_ID=$(USER)
NEXT_PUBLIC_API_URL=http://localhost:8765 NEXT_PUBLIC_API_URL=http://localhost:8765
@@ -16,55 +16,37 @@ help:
@echo " make test-clean - Run tests and clean up volumes" @echo " make test-clean - Run tests and clean up volumes"
@echo " make ui-install - Install frontend dependencies" @echo " make ui-install - Install frontend dependencies"
@echo " make ui-start - Start the frontend development server" @echo " make ui-start - Start the frontend development server"
@echo " make ui - Install dependencies and start the frontend" @echo " make ui-dev - Install dependencies and start the frontend in dev mode"
@echo " make ui - Install dependencies and start the frontend in production mode"
env: env:
cd api && cp .env.example .env cd api && cp .env.example .env
cd ui && cp .env.example .env
build: build:
cd api && docker-compose build docker compose build
up: up:
cd api && docker-compose up NEXT_PUBLIC_USER_ID=$(USER) NEXT_PUBLIC_API_URL=$(NEXT_PUBLIC_API_URL) docker compose up
down: down:
cd api && docker-compose down -v docker compose down -v
rm -f api/openmemory.db rm -f api/openmemory.db
logs: logs:
cd api && docker-compose logs -f docker compose logs -f
shell: shell:
cd api && docker-compose exec api bash docker compose exec api bash
upgrade: upgrade:
cd api && docker-compose exec api alembic upgrade head docker compose exec api alembic upgrade head
migrate: migrate:
cd api && docker-compose exec api alembic upgrade head docker compose exec api alembic upgrade head
downgrade: downgrade:
cd api && docker-compose exec api alembic downgrade -1 docker compose exec api alembic downgrade -1
test: ui-dev:
cd api && docker-compose run --rm api pytest tests/ -v cd ui && NEXT_PUBLIC_USER_ID=$(USER) NEXT_PUBLIC_API_URL=$(NEXT_PUBLIC_API_URL) pnpm install && pnpm dev
test-clean:
cd api && docker-compose run --rm api pytest tests/ -v && docker-compose down -v
# Frontend commands
ui-install:
cd ui && pnpm install
ui-build:
cd ui && pnpm build
ui-start:
cd ui && NEXT_PUBLIC_USER_ID=$(USER) NEXT_PUBLIC_API_URL=$(NEXT_PUBLIC_API_URL) pnpm start
ui-dev-start:
cd ui && NEXT_PUBLIC_USER_ID=$(USER) NEXT_PUBLIC_API_URL=$(NEXT_PUBLIC_API_URL) && pnpm dev
ui-dev: ui-install ui-dev-start
ui: ui-install ui-build ui-start

View File

@@ -15,9 +15,8 @@ OpenMemory is your personal memory layer for LLMs - private, portable, and open-
You can run the project using the following two commands: You can run the project using the following two commands:
```bash ```bash
make build # builds the mcp server make build # builds the mcp server and ui
make up # runs openmemory mcp server make up # runs openmemory mcp server and ui
make ui # runs openmemory ui
``` ```
After running these commands, you will have: After running these commands, you will have:

View File

@@ -1,2 +1 @@
OPENAI_API_KEY=sk-... OPENAI_API_KEY=sk-xxx
USER=username

View File

@@ -11,7 +11,14 @@ The easiest way to get started is using Docker. Make sure you have Docker and Do
make build make build
``` ```
2. Start the services: 2. Create `.env` file:
```bash
make env
```
Once you run this command, edit the file `api/.env` and enter the `OPENAI_API_KEY`.
3. Start the services:
```bash ```bash
make up make up
``` ```

View File

@@ -5,22 +5,31 @@ services:
- "6333:6333" - "6333:6333"
volumes: volumes:
- mem0_storage:/mem0/storage - mem0_storage:/mem0/storage
api: openmemory-mcp:
image: mem0/openmemory-mcp image: mem0/openmemory-mcp
build: . build: api/
environment: environment:
- OPENAI_API_KEY
- USER - USER
env_file: env_file:
- .env - api/.env
depends_on: depends_on:
- mem0_store - mem0_store
ports: ports:
- "8765:8765" - "8765:8765"
volumes: volumes:
- .:/usr/src/openmemory - ./api:/usr/src/openmemory
command: > command: >
sh -c "uvicorn main:app --host 0.0.0.0 --port 8765 --reload --workers 4" sh -c "uvicorn main:app --host 0.0.0.0 --port 8765 --reload --workers 4"
openmemory-ui:
build:
context: ui/
dockerfile: Dockerfile
image: mem0/openmemory-ui:latest
ports:
- "3000:3000"
environment:
- NEXT_PUBLIC_API_URL=${NEXT_PUBLIC_API_URL}
- NEXT_PUBLIC_USER_ID=${USER}
volumes: volumes:
mem0_storage: mem0_storage:

View File

@@ -1,2 +0,0 @@
NEXT_PUBLIC_API_URL=NEXT_PUBLIC_API_URL
NEXT_PUBLIC_USER_ID=NEXT_PUBLIC_USER_ID

View File

@@ -1,2 +1,2 @@
NEXT_PUBLIC_API_URL=http://localhost:8765 NEXT_PUBLIC_API_URL=NEXT_PUBLIC_API_URL
NEXT_PUBLIC_USER_ID=default-user NEXT_PUBLIC_USER_ID=NEXT_PUBLIC_USER_ID

View File

@@ -10,16 +10,12 @@ RUN apk add --no-cache libc6-compat curl && \
WORKDIR /app WORKDIR /app
# Dependencies stage
FROM base AS deps FROM base AS deps
# Copy lockfile and manifest
COPY package.json pnpm-lock.yaml ./ COPY package.json pnpm-lock.yaml ./
# Install dependencies using pnpm
RUN pnpm install --frozen-lockfile RUN pnpm install --frozen-lockfile
# Builder stage
FROM base AS builder FROM base AS builder
WORKDIR /app WORKDIR /app
@@ -28,30 +24,24 @@ COPY --from=deps /app/pnpm-lock.yaml ./pnpm-lock.yaml
COPY . . COPY . .
RUN cp next.config.dev.mjs next.config.mjs RUN cp next.config.dev.mjs next.config.mjs
RUN cp .env.dev .env RUN cp .env.example .env
RUN pnpm build RUN pnpm build
# Production runner stage
FROM base AS runner FROM base AS runner
WORKDIR /app WORKDIR /app
ENV NODE_ENV=production ENV NODE_ENV=production
# Create non-root user for security
RUN addgroup --system --gid 1001 nodejs && \ RUN addgroup --system --gid 1001 nodejs && \
adduser --system --uid 1001 nextjs adduser --system --uid 1001 nextjs
# Copy production dependencies and built artifacts
COPY --from=builder /app/public ./public COPY --from=builder /app/public ./public
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./ COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
# Copy and prepare entrypoint script
COPY --chown=nextjs:nodejs entrypoint.sh /home/nextjs/entrypoint.sh COPY --chown=nextjs:nodejs entrypoint.sh /home/nextjs/entrypoint.sh
RUN chmod +x /home/nextjs/entrypoint.sh RUN chmod +x /home/nextjs/entrypoint.sh
# Switch to non-root user
USER nextjs USER nextjs
EXPOSE 3000 EXPOSE 3000

View File

@@ -1,13 +0,0 @@
services:
frontend:
build:
context: .
dockerfile: Dockerfile
image: mem0/openmemory-ui:latest
ports:
- "3000:3000"
env_file:
- .env
environment:
- NEXT_PUBLIC_API_URL=NEXT_PUBLIC_API_URL
- NEXT_PUBLIC_USER_ID=NEXT_PUBLIC_USER_ID