Add docker file

This commit is contained in:
alonso.torres 2025-12-10 15:51:17 +01:00
parent c931e6978b
commit 71a7ec214e
4 changed files with 83 additions and 3 deletions

37
Dockerfile Normal file
View File

@ -0,0 +1,37 @@
## ------ Build
FROM node:22.21.1 AS build
RUN set -ex; \
apt update ; \
apt -y install python3 python3-venv pip
RUN python3 -m venv /opt/venv
WORKDIR /app
ENV PATH="/opt/venv/bin:$PATH"
COPY requirements.txt .
RUN pip install -Ur requirements.txt
COPY . .
RUN set -ex; \
cd mcp-server; \
npm install --frozen-lockfile; \
npm run build;
# MCP API Server
EXPOSE 4401
# WebSocket server
EXPOSE 4402
# Repl server
EXPOSE 4403
ENV PLUGIN_API_URL="https://penpot-plugins-api-doc.pages.dev/"
#ENTRYPOINT node ./dist/index.js
CMD [ "./docker-entrypoint.sh" ]

7
docker-entrypoint.sh Executable file
View File

@ -0,0 +1,7 @@
#!/bin/bash
echo "Parsing: $PLUGIN_API_URL"
(cd python-scripts && python prepare_api_docs.py $PLUGIN_API_URL)
(cd mcp-server && node dist/index.js --multi-user)

View File

@ -11,9 +11,11 @@ from markdownify import MarkdownConverter
from ruamel.yaml import YAML from ruamel.yaml import YAML
from ruamel.yaml.scalarstring import LiteralScalarString from ruamel.yaml.scalarstring import LiteralScalarString
from sensai.util import logging from sensai.util import logging
import sys
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
DEFAULT_API_DOCS_URL="https://penpot-plugins-api-doc.pages.dev"
class PenpotAPIContentMarkdownConverter(MarkdownConverter): class PenpotAPIContentMarkdownConverter(MarkdownConverter):
""" """
@ -131,9 +133,9 @@ class YamlConverter:
class PenpotAPIDocsProcessor: class PenpotAPIDocsProcessor:
def __init__(self): def __init__(self, url=None):
self.md_converter = PenpotAPIContentMarkdownConverter() self.md_converter = PenpotAPIContentMarkdownConverter()
self.base_url = "https://penpot-plugins-api-doc.pages.dev" self.base_url = DEFAULT_API_DOCS_URL
self.types: dict[str, TypeInfo] = {} self.types: dict[str, TypeInfo] = {}
self.type_referenced_by: dict[str, set[str]] = collections.defaultdict(set) self.type_referenced_by: dict[str, set[str]] = collections.defaultdict(set)
@ -234,7 +236,10 @@ class PenpotAPIDocsProcessor:
def main(): def main():
target_dir = Path(__file__).parent.parent / "mcp-server" / "data" target_dir = Path(__file__).parent.parent / "mcp-server" / "data"
PenpotAPIDocsProcessor().run(target_dir=str(target_dir)) url = sys.argv[1] if len(sys.argv) > 1 else DEFAULT_API_DOCS_URL
print("Fetching plugin data from: {}".format(url))
PenpotAPIDocsProcessor(url).run(target_dir=str(target_dir))
def debug_type_conversion(rel_url: str): def debug_type_conversion(rel_url: str):

31
requirements.txt Normal file
View File

@ -0,0 +1,31 @@
beautifulsoup4==4.14.3
certifi==2025.11.12
charset-normalizer==3.4.4
contourpy==1.3.3
cycler==0.12.1
fonttools==4.61.0
idna==3.11
joblib==1.5.2
kiwisolver==1.4.9
markdownify==1.2.2
matplotlib==3.10.7
numpy==2.3.5
packaging==25.0
pandas==2.3.3
pillow==12.0.0
pyparsing==3.2.5
python-dateutil==2.9.0.post0
pytz==2025.2
requests==2.32.5
ruamel.yaml==0.18.16
ruamel.yaml.clib==0.2.15
scikit-learn==1.7.2
scipy==1.16.3
seaborn==0.13.2
sensai==1.6.0
six==1.17.0
soupsieve==2.8
threadpoolctl==3.6.0
typing_extensions==4.15.0
tzdata==2025.2
urllib3==2.5.0