-
Notifications
You must be signed in to change notification settings - Fork 15
feat: enhance MCP server deployment instructions and add Docker support #322
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| # syntax=docker/dockerfile:1 | ||
|
|
||
| FROM python:3.12-slim | ||
|
|
||
| # Create a non-root user | ||
| RUN useradd --create-home --shell /bin/bash appuser | ||
|
|
||
| WORKDIR /app | ||
|
|
||
| # Accept the .whl filename as a build argument | ||
| ARG WHL_FILE | ||
| ARG VISION_BACKEND=easyocr | ||
|
|
||
| ENV VISION_BACKEND=${VISION_BACKEND} | ||
| ENV WHL_FILE=${WHL_FILE} | ||
|
|
||
| # Copy wheel(s) from dist/ (empty WHL_FILE copies all of dist/, matching Docker/dev/Dockerfile) | ||
| COPY dist/${WHL_FILE} /app/ | ||
|
|
||
|
|
||
| # Install system dependencies (first layer for cache) | ||
| RUN apt-get update && apt-get install --no-install-recommends -y \ | ||
| build-essential \ | ||
| curl \ | ||
| libgl1 \ | ||
| libglib2.0-0 \ | ||
| xvfb \ | ||
| dbus-x11 \ | ||
| tesseract-ocr \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
|
|
||
| # Install common Python packages and optics-framework wheel with MCP extra and vision backend | ||
| RUN pip install --no-cache-dir \ | ||
| appium-python-client playwright \ | ||
| && playwright install-deps chromium firefox \ | ||
| && WHEEL=$(if [ -n "$WHL_FILE" ]; then echo "/app/${WHL_FILE}"; else ls /app/*.whl 2>/dev/null | head -1; fi) \ | ||
| && if [ -z "$WHEEL" ] || [ ! -f "$WHEEL" ]; then \ | ||
| echo "ERROR: No wheel in dist/. Run 'poetry build' first or set WHL_FILE to the .whl filename."; \ | ||
| exit 1; \ | ||
| fi \ | ||
| && pip install --no-cache-dir "${WHEEL}[mcp]" \ | ||
| && if [ "$VISION_BACKEND" = "easyocr" ]; then \ | ||
| pip install --no-cache-dir easyocr; \ | ||
| elif [ "$VISION_BACKEND" = "google-vision" ]; then \ | ||
| pip install --no-cache-dir google-cloud-vision; \ | ||
| elif [ "$VISION_BACKEND" = "pytesseract" ]; then \ | ||
| pip install --no-cache-dir pytesseract; \ | ||
| fi | ||
|
|
||
| # If using google-vision, user must mount service account json and set GOOGLE_APPLICATION_CREDENTIALS | ||
| # Example: docker run -e GOOGLE_APPLICATION_CREDENTIALS=/app/service-account.json -v /path/to/service-account.json:/app/service-account.json ... | ||
|
|
||
| # Set permissions | ||
| RUN chown -R appuser:appuser /app | ||
|
|
||
| # Switch to non-root user | ||
| USER appuser | ||
|
|
||
| # Pre-download EasyOCR models as appuser (must match runtime user's ~/.EasyOCR/) | ||
| RUN if [ "$VISION_BACKEND" = "easyocr" ]; then \ | ||
|
Check warning on line 60 in Docker/mcp/dev/Dockerfile
|
||
| python3 -c "import easyocr; easyocr.Reader(['en'], download_enabled=True)"; \ | ||
| fi | ||
|
|
||
| # Install Playwright browsers (Chromium and Firefox) as appuser (must be done as the user who will run the app) | ||
| RUN playwright install chromium firefox | ||
|
|
||
| EXPOSE 8090 | ||
|
|
||
| # Allow dynamic port via MCP_PORT env variable (default 8090) | ||
| ENV MCP_PORT=8090 | ||
|
|
||
| # Set DISPLAY for X11 (xvfb will provide virtual display) | ||
| ENV DISPLAY=:99 | ||
|
|
||
| # Use exec form for CMD with shell for env var substitution | ||
| # Start xvfb in the background, then run optics mcp over HTTP | ||
| CMD ["/bin/sh", "-c", "Xvfb :99 -screen 0 1280x1024x24 > /dev/null 2>&1 & exec optics mcp --transport http --host 0.0.0.0 --port \"${MCP_PORT:-8090}\""] | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| # syntax=docker/dockerfile:1 | ||
| FROM python:3.12-slim | ||
|
|
||
| # Create a non-root user | ||
| RUN useradd --create-home --shell /bin/bash appuser | ||
|
|
||
| # Set working directory | ||
| WORKDIR /app | ||
|
|
||
| # Build arguments for vision backend | ||
| ARG VISION_BACKEND=easyocr | ||
| ENV VISION_BACKEND=${VISION_BACKEND} | ||
|
|
||
|
|
||
| # Install system dependencies (first layer for cache) | ||
| RUN apt-get update && apt-get install --no-install-recommends -y \ | ||
| build-essential \ | ||
| curl \ | ||
| libgl1 \ | ||
| libglib2.0-0 \ | ||
| xvfb \ | ||
| dbus-x11 \ | ||
| tesseract-ocr \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
|
|
||
| RUN pip install --no-cache-dir uv \ | ||
| && uv pip install --system appium-python-client playwright \ | ||
| && playwright install-deps chromium firefox | ||
|
|
||
| # Install optics-framework with MCP extra and vision backend (late layer for cache efficiency) | ||
| RUN uv pip install --system "optics-framework[mcp]" \ | ||
| && if [ "$VISION_BACKEND" = "easyocr" ]; then \ | ||
| uv pip install --system easyocr; \ | ||
| elif [ "$VISION_BACKEND" = "google-vision" ]; then \ | ||
| uv pip install --system google-cloud-vision; \ | ||
| elif [ "$VISION_BACKEND" = "pytesseract" ]; then \ | ||
|
malto101 marked this conversation as resolved.
|
||
| uv pip install --system pytesseract; \ | ||
| fi | ||
|
|
||
| # If using google-vision, user must mount service account json and set GOOGLE_APPLICATION_CREDENTIALS | ||
| # Example: docker run -e GOOGLE_APPLICATION_CREDENTIALS=/app/service-account.json -v /path/to/service-account.json:/app/service-account.json ... | ||
|
|
||
| # Set permissions | ||
| RUN chown -R appuser:appuser /app | ||
|
|
||
| # Switch to non-root user to install Playwright browsers in user's cache | ||
| USER appuser | ||
|
|
||
| # Pre-download EasyOCR models as appuser (must match runtime user's ~/.EasyOCR/) | ||
| RUN if [ "$VISION_BACKEND" = "easyocr" ]; then \ | ||
|
Check warning on line 50 in Docker/mcp/prod/Dockerfile
|
||
| python3 -c "import easyocr; easyocr.Reader(['en'], download_enabled=True)"; \ | ||
| fi | ||
|
|
||
| # Install Playwright browsers (Chromium and Firefox) as appuser (must be done as the user who will run the app) | ||
| RUN playwright install chromium firefox | ||
|
|
||
| # Note: We stay as appuser for the rest of the Dockerfile | ||
|
|
||
| EXPOSE 8090 | ||
|
|
||
| # Allow dynamic port via MCP_PORT env variable (default 8090) | ||
| ENV MCP_PORT=8090 | ||
|
|
||
| # Set DISPLAY for X11 (xvfb will provide virtual display) | ||
| ENV DISPLAY=:99 | ||
|
|
||
| # Use exec form for CMD with shell for env var substitution | ||
| # Start xvfb in the background, then run optics mcp over HTTP | ||
| CMD ["/bin/sh", "-c", "Xvfb :99 -screen 0 1280x1024x24 > /dev/null 2>&1 & exec optics mcp --transport http --host 0.0.0.0 --port \"${MCP_PORT:-8090}\""] | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.