diff --git a/compose.yml b/compose.yml index b0744fb..9e1199b 100644 --- a/compose.yml +++ b/compose.yml @@ -1,7 +1,10 @@ services: mcp-bridge: build: - context: . + context: ./docker + additional_contexts: + requirements: . + dockerfile: Dockerfile develop: watch: - path: mcp_bridge @@ -15,4 +18,7 @@ services: # - MCP_BRIDGE__CONFIG__JSON= # volumes: # - ./config.json:/mcp_bridge/config.json + volumes: + - ./docker/config.json.template:/mcp_bridge/config.json.template restart: unless-stopped + env_file: ./creds.env diff --git a/creds.env.template b/creds.env.template new file mode 100644 index 0000000..f108023 --- /dev/null +++ b/creds.env.template @@ -0,0 +1,5 @@ +#############open ai##################### +OPENAI_API_KEY= +OPENAI_API_BASE_URL= +#########MCP Bridge############### +MCP_BRIDGE_LOG_LEVEL= \ No newline at end of file diff --git a/Dockerfile b/docker/Dockerfile similarity index 50% rename from Dockerfile rename to docker/Dockerfile index e3d425b..1263b9e 100644 --- a/Dockerfile +++ b/docker/Dockerfile @@ -4,22 +4,24 @@ FROM python:3.12-bullseye RUN pip install --no-cache-dir uv # install npx to run stdio clients (npx) -RUN apt-get update && apt-get install -y --no-install-recommends curl +RUN apt-get update && apt-get install -y --no-install-recommends curl gettext RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - RUN apt-get install -y --no-install-recommends nodejs -COPY pyproject.toml . +COPY --from=requirements pyproject.toml pyproject.toml -## FOR GHCR BUILD PIPELINE -COPY mcp_bridge/__init__.py mcp_bridge/__init__.py -COPY README.md README.md +## FOR GHCR BUILD PIPELINE +COPY --from=requirements README.md README.md +COPY --from=requirements mcp_bridge/__init__.py mcp_bridge/__init__.py +COPY --from=requirements mcp_bridge mcp_bridge RUN uv sync -COPY mcp_bridge mcp_bridge EXPOSE 8000 -WORKDIR /mcp_bridge -ENTRYPOINT ["uv", "run", "main.py"] +COPY config.json.template config.json.template +COPY entrypoint.sh entrypoint.sh + +ENTRYPOINT ["bash", "entrypoint.sh"] diff --git a/docker/config.json.template b/docker/config.json.template new file mode 100644 index 0000000..f9adc57 --- /dev/null +++ b/docker/config.json.template @@ -0,0 +1,15 @@ +{ + "inference_server": { + "base_url": "${OPENAI_API_BASE_URL}", + "api_key": "${OPENAI_API_KEY}" + }, + "mcp_servers": { + "fetch": { + "command": "uvx", + "args": ["mcp-server-fetch"] + } + }, + "logging": { + "log_level": "${MCP_BRIDGE_LOG_LEVEL}" + } +} \ No newline at end of file diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh new file mode 100644 index 0000000..70b900a --- /dev/null +++ b/docker/entrypoint.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +echo "generating config.json" && \ +echo "........................." && \ +envsubst < config.json.template > config.json && \ +echo "starting mcp_bridge........." && \ +uv run python mcp_bridge/main.py \ No newline at end of file