# Cubic Echo: MCP servers, for QNAP Container Station 3
# Applications → Create, paste this in, then Validate YAML and Create.
# Guide: https://cubicecho.com/guides/mcp/  ·  QNAP: https://cubicecho.com/guides/qnap/
#
# Container Station reads no .env file, so replace each of these everywhere
# it appears (generate secrets with `openssl rand -hex 32`):
#   CHANGE_ME_POSTGRES_PASSWORD
#   CHANGE_ME_SKILLS_AUTH_SECRET
#   CHANGE_ME_PUBLIC_HOST
#   CHANGE_ME_RAGDOWN_TOKEN
#   CHANGE_ME_ACTUAL_SERVER_URL
#   CHANGE_ME_ACTUAL_PASSWORD
#   CHANGE_ME_ACTUAL_SYNC_ID
#   CHANGE_ME_ACTUAL_MCP_TOKEN
# NOTES_DIR is set to /share/Container/mcp-ragdown/notes; create that folder in File Station first.
name: cubicecho-mcp

services:
  mcp-skills-manager:
    image: ghcr.io/cubicecho/mcp-skills-manager:latest
    restart: unless-stopped
    depends_on:
      postgres: { condition: service_healthy }
    environment:
      DATABASE_URL: postgres://cubicecho:CHANGE_ME_POSTGRES_PASSWORD@postgres:5432/mcp_skills
      BETTER_AUTH_SECRET: CHANGE_ME_SKILLS_AUTH_SECRET
      APP_URL: http://CHANGE_ME_PUBLIC_HOST:3100
      OIDC_ISSUER: ""   # or pair with heautou from the sign-in page
      OIDC_CLIENT_ID: ""
      OIDC_CLIENT_SECRET: ""
      OIDC_CLIENT_AUTH: ""
      OIDC_NAME: ""
      SECURE_LOCAL_NET: ""
      TRUST_PROXY: false
    ports:
      - "3100:3000"
    volumes:
      - skills-data:/data

  mcp-ragdown:
    image: vantreeseba/mcp-ragdown:latest
    restart: unless-stopped
    environment:
      RAGDOWN_TOKEN: CHANGE_ME_RAGDOWN_TOKEN
      RAGDOWN_READ_ONLY: false
      RAGDOWN_PUBLIC_URL: ""
      SECURE_LOCAL_NET: false
    ports:
      - "3102:3000"
    volumes:
      - /share/Container/mcp-ragdown/notes:/docs
      - ragdown-data:/data

  mcp-actual:
    image: ghcr.io/cubicecho/mcp-actual:latest
    restart: unless-stopped
    environment:
      ACTUAL_SERVER_URL: CHANGE_ME_ACTUAL_SERVER_URL
      ACTUAL_PASSWORD: CHANGE_ME_ACTUAL_PASSWORD
      ACTUAL_SYNC_ID: CHANGE_ME_ACTUAL_SYNC_ID
      ACTUAL_ENCRYPTION_PASSWORD: ""
      ACTUAL_ENABLE_WRITES: ""
      MCP_ACTUAL_TOKEN: CHANGE_ME_ACTUAL_MCP_TOKEN
      SECURE_LOCAL_NET: ""
      DATA_DIR: /data
    ports:
      - "3101:3000"
    volumes:
      - actual-data:/data

  # mcp-skills-manager needs Postgres 18 or later; the other two need none.
  postgres:
    image: postgres:18-alpine
    restart: unless-stopped
    environment:
      POSTGRES_USER: cubicecho
      POSTGRES_PASSWORD: CHANGE_ME_POSTGRES_PASSWORD
      POSTGRES_DB: cubicecho
    configs:
      - source: create-databases
        target: /docker-entrypoint-initdb.d/create-databases.sql
    volumes:
      - postgres-data:/var/lib/postgresql
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U cubicecho -d cubicecho"]
      interval: 5s
      timeout: 5s
      retries: 10

# Runs once, when the Postgres volume is first created.
configs:
  create-databases:
    content: |
      CREATE DATABASE mcp_skills;

volumes:
  skills-data:
  ragdown-data:
  actual-data:
  postgres-data:
