ソースを参照

news-mcp: add docker compose persistence setup

Lukas Goldschmidt 1 ヶ月 前
コミット
74e3b0f555
5 ファイル変更53 行追加0 行削除
  1. 8 0
      .dockerignore
  2. 19 0
      Dockerfile
  3. 6 0
      README.md
  4. 17 0
      docker-compose.yml
  5. 3 0
      news_mcp/storage/sqlite_store.py

+ 8 - 0
.dockerignore

@@ -0,0 +1,8 @@
+.git
+__pycache__
+.pytest_cache
+.venv
+logs
+*.log
+server.pid
+uvicorn.log

+ 19 - 0
Dockerfile

@@ -0,0 +1,19 @@
+FROM python:3.13-slim
+
+WORKDIR /app
+
+ENV PYTHONDONTWRITEBYTECODE=1 \
+    PYTHONUNBUFFERED=1
+
+RUN apt-get update \
+    && apt-get install -y --no-install-recommends build-essential curl \
+    && rm -rf /var/lib/apt/lists/*
+
+COPY requirements.txt ./requirements.txt
+RUN pip install --no-cache-dir -r requirements.txt
+
+COPY . .
+
+EXPOSE 8506
+
+CMD ["uvicorn", "news_mcp.mcp_server_fastmcp:app", "--host", "0.0.0.0", "--port", "8506"]

+ 6 - 0
README.md

@@ -4,6 +4,7 @@ FastMCP-based MCP server that turns news feeds into **deduplicated, enriched clu
 
 ## Quick start
 
+Local:
 ```bash
 cd news-mcp
 source .venv/bin/activate
@@ -11,6 +12,11 @@ pip install -r requirements.txt
 ./run.sh
 ```
 
+Docker Compose:
+```bash
+docker compose up --build
+```
+
 Default SSE mount (FastMCP):
 - `http://127.0.0.1:8506/mcp/sse`
 

+ 17 - 0
docker-compose.yml

@@ -0,0 +1,17 @@
+services:
+  news-mcp:
+    build: .
+    container_name: news-mcp
+    env_file:
+      - .env
+    environment:
+      NEWS_MCP_DATA_DIR: ./data
+      NEWS_MCP_DB_PATH: ./data/news.sqlite
+      NEWS_PROMPTS_DIR: ./prompts
+      NEWS_ENTITY_ALIASES_FILE: ./config/entity_aliases.json
+    working_dir: /app
+    volumes:
+      - ./:/app
+    ports:
+      - "8506:8506"
+    restart: unless-stopped

+ 3 - 0
news_mcp/storage/sqlite_store.py

@@ -99,6 +99,9 @@ class SQLiteClusterStore:
     def _init_db(self) -> None:
         Path(self.db_path).parent.mkdir(parents=True, exist_ok=True)
         with self._conn() as conn:
+            conn.execute("PRAGMA journal_mode=WAL")
+            conn.execute("PRAGMA synchronous=NORMAL")
+            conn.execute("PRAGMA busy_timeout=5000")
             conn.execute(
                 """
                 CREATE TABLE IF NOT EXISTS clusters (