From bd4f49fcce904f3150970c21725563591b05bbf0 Mon Sep 17 00:00:00 2001 From: lixiangcheng1 Date: Mon, 22 Dec 2025 17:52:00 +0800 Subject: [PATCH] [fix]update dockerfile --- api/Dockerfile | 28 ++++++--------------- api/docker-compose.yml | 55 +++++++++++++++++++++++++++++++++++++++--- 2 files changed, 60 insertions(+), 23 deletions(-) diff --git a/api/Dockerfile b/api/Dockerfile index a5c818ea..f6c082d2 100644 --- a/api/Dockerfile +++ b/api/Dockerfile @@ -25,17 +25,13 @@ ENV DEBIAN_FRONTEND=noninteractive # 4. Setup apt # Python package and implicit dependencies: # opencv-python: libglib2.0-0 libglx-mesa0 libgl1 -# aspose-slides: pkg-config libicu-dev libgdiplus libssl1.1_1.1.1f-1ubuntu2_amd64.deb -# python-pptx: default-jdk tika-server-standard-3.0.0.jar +# libreoffice: libreoffice libreoffice-writer libreoffice-impress fonts-wqy-zenhei fonts-noto-cjk +# python-docx: default-jdk tika-server-standard-3.0.0.jar # Building C extensions: libpython3-dev libgtk-4-1 libnss3 xdg-utils libgbm-dev RUN --mount=type=cache,id=mem_apt,target=/var/cache/apt,sharing=locked \ - apt install -y libicu-dev && \ if [ "$NEED_MIRROR" == "1" ]; then \ - rm -f /etc/apt/sources.list.d/debian.sources && \ - echo "deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm main contrib non-free non-free-firmware" > /etc/apt/sources.list && \ - echo "deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-updates main contrib non-free non-free-firmware" >> /etc/apt/sources.list && \ - echo "deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-backports main contrib non-free non-free-firmware" >> /etc/apt/sources.list && \ - echo "deb https://mirrors.tuna.tsinghua.edu.cn/debian-security bookworm-security main contrib non-free non-free-firmware" >> /etc/apt/sources.list; \ + sed -i 's|http://ports.ubuntu.com|http://mirrors.tuna.tsinghua.edu.cn|g' /etc/apt/sources.list; \ + sed -i 's|http://archive.ubuntu.com|http://mirrors.tuna.tsinghua.edu.cn|g' /etc/apt/sources.list; \ fi; \ rm -f /etc/apt/apt.conf.d/docker-clean && \ echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache && \ @@ -44,7 +40,7 @@ RUN --mount=type=cache,id=mem_apt,target=/var/cache/apt,sharing=locked \ apt --no-install-recommends install -y ca-certificates && \ apt update && \ apt install -y libglib2.0-0 libglx-mesa0 libgl1 && \ - apt install -y pkg-config libgdiplus && \ + apt install -y libreoffice libreoffice-writer libreoffice-impress fonts-wqy-zenhei fonts-noto-cjk && \ apt install -y default-jdk && \ apt install -y libpython3-dev libgtk-4-1 libnss3 xdg-utils libgbm-dev && \ apt install -y libjemalloc-dev && \ @@ -64,21 +60,13 @@ RUN if [ "$NEED_MIRROR" == "1" ]; then \ ENV PYTHONDONTWRITEBYTECODE=1 DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=1 ENV PATH=/root/.local/bin:$PATH -# https://forum.aspose.com/t/aspose-slides-for-net-no-usable-version-of-libssl-found-with-linux-server/271344/13 -# 5. aspose-slides on linux/arm64 is unavailable -COPY libssl1.1_1.1.1f-1ubuntu2_amd64.deb libssl1.1_1.1.1f-1ubuntu2_arm64.deb /tmp/ -RUN if [ "$(uname -m)" = "x86_64" ]; then \ - dpkg -i /tmp/libssl1.1_1.1.1f-1ubuntu2_amd64.deb; \ - elif [ "$(uname -m)" = "aarch64" ]; then \ - dpkg -i /tmp/libssl1.1_1.1.1f-1ubuntu2_arm64.deb; \ - fi && \ - rm -f /tmp/libssl1.1_*.deb - -# 6. install dependencies from uv.lock file +# 5. install dependencies from uv.lock file COPY ./pyproject.toml /code/pyproject.toml COPY ./uv.lock /code/uv.lock COPY ./app /code/app +COPY ./alembic.ini /code/alembic.ini +COPY ./migrations /code/migrations # https://github.com/astral-sh/uv/issues/10462 # uv records index url into uv.lock but doesn't failover among multiple indexes diff --git a/api/docker-compose.yml b/api/docker-compose.yml index 74c69353..48ec137d 100644 --- a/api/docker-compose.yml +++ b/api/docker-compose.yml @@ -1,22 +1,71 @@ -version: '3.8' +version: '3.9' services: + # MCP Server - standalone service + mcp-server: + image: redbear-mem:latest + container_name: mcp-server + ports: + - "8081:8081" # MCP server port + env_file: + - .env + environment: + - SERVER_IP=0.0.0.0 # Bind to all interfaces + volumes: + - ./files:/files + - /etc/localtime:/etc/localtime:ro + command: python -m app.core.memory.agent.mcp_server.server + healthcheck: + test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:8081/sse')"] + interval: 10s + timeout: 5s + retries: 5 + start_period: 30s + restart: unless-stopped + networks: + - default + - celery + + # FastAPI application - connects to MCP server api: image: redbear-mem:latest container_name: api ports: - - "8000:8000" + - "8002:8000" env_file: - .env + environment: + - MCP_SERVER_URL=http://mcp-server:8081 + - SERVER_IP=0.0.0.0 # Ensure MCP server binds to all interfaces volumes: - ./files:/files + - /etc/localtime:/etc/localtime:ro command: uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload --log-level debug + depends_on: + mcp-server: + condition: service_healthy + restart: unless-stopped + networks: + - default + - celery + # Celery worker - connects to MCP server worker: image: redbear-mem:latest container_name: worker env_file: - .env + environment: + - MCP_SERVER_URL=http://mcp-server:8081 volumes: - ./files:/files - command: celery -A app.celery_worker.celery_app worker --loglevel=info \ No newline at end of file + - /etc/localtime:/etc/localtime:ro + command: celery -A app.celery_worker.celery_app worker --loglevel=info + depends_on: + mcp-server: + condition: service_healthy + restart: unless-stopped + networks: + - celery +networks: + celery: \ No newline at end of file