diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..31bf906 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,5 @@ +.git +__pycache__ +node_modules +build +core \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5a6f35c..30b8fcc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -53,4 +53,9 @@ jobs: run: | export LOADER_LIBRARY_PATH="/usr/local/lib" export LOADER_SCRIPT_PATH="/home/runner/work/polyglot-tree-traversal/polyglot-tree-traversal" # path of the scripts - metacallcli rootNode.py \ No newline at end of file + metacallcli rootNode.py + + - name: Test Docker Build + run: | + docker build --tag metacall/polyglot-tree-traversal-example . + docker run --rm -e LOADER_LIBRARY_PATH="/usr/local/lib" -e LOADER_SCRIPT_PATH="/root/polyglot-tree-traversal-example" metacall/polyglot-tree-traversal-example \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ed8ebf5 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +__pycache__ \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..48e29ab --- /dev/null +++ b/Dockerfile @@ -0,0 +1,58 @@ +# Use Ubuntu as the base image +FROM ubuntu:latest + +# Install dependencies +RUN apt-get update \ + && apt-get install -y --no-install-recommends \ + ca-certificates \ + build-essential \ + cmake \ + curl \ + nodejs \ + git \ + npm \ + python3 \ + python3-dev \ + && rm -rf /var/lib/apt/lists/* + + +# Set working directory +WORKDIR /root + +# Clone the repository +RUN git clone https://github.com/metacall/polyglot-tree-traversal-example.git + +# Change working directory to polyglot-tree-traversal-example +WORKDIR /root/polyglot-tree-traversal-example + +# Clone and build METACALL +RUN git clone --branch v0.8.7 https://github.com/metacall/core \ + && cd core \ + && ./tools/metacall-environment.sh release base nodejs c python \ + && mkdir build && cd build \ + && cmake \ + -DOPTION_BUILD_LOADERS_C=On \ + -DOPTION_BUILD_LOADERS_NODE=On \ + -DOPTION_BUILD_LOADERS_PY=On \ + -DOPTION_BUILD_PORTS=On \ + -DOPTION_BUILD_PORTS_NODE=On \ + -DOPTION_BUILD_PORTS_PY=On \ + -DOPTION_BUILD_DETOURS=Off \ + -DOPTION_BUILD_SCRIPTS=Off \ + -DOPTION_BUILD_TESTS=Off \ + -DOPTION_BUILD_EXAMPLES=Off \ + .. \ + && cmake --build . --target install \ + && ldconfig /usr/local/lib \ + && cd ../../ \ + && rm -rf core + +# Set environment variables for METACALL +ENV LOADER_LIBRARY_PATH="/usr/local/lib" \ + LOADER_SCRIPT_PATH="/root/polyglot-tree-traversal-example" + +# testing the build +RUN ["metacallcli", "rootNode.py"] + +# Run the application +CMD ["metacallcli", "rootNode.py"] diff --git a/Readme.md b/Readme.md index 5d6a951..e45f3e9 100644 --- a/Readme.md +++ b/Readme.md @@ -97,4 +97,17 @@ This will initiate the traversal of the polyglot tree, starting with the Python - Ensure that MetaCall loaders for Python, Node.js, and C are enabled during the build. - Ensure that MetaCall ports for Nodejs and Python are enabled during the build. -- Scripts should be placed in the directory specified by the `LOADER_SCRIPT_PATH` environment variable. \ No newline at end of file +- Scripts should be placed in the directory specified by the `LOADER_SCRIPT_PATH` environment variable. + +## 🚀 Running with Docker +You can run the Polyglot Tree Traversal Example inside a Docker container without installing dependencies manually. +📌 Build the Docker Image +Run the following command to build the Docker image: +```sh + docker build --tag metacall/polyglot-tree-traversal-example . +``` +▶️ Run the Container +Execute the container with: +```sh + docker run --rm -e LOADER_LIBRARY_PATH="/usr/local/lib" -e LOADER_SCRIPT_PATH="/root/polyglot-tree-traversal-example" metacall/polyglot-tree-traversal-example +``` \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..5c74b46 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,13 @@ +verison: '3.8' +services: + polyglot-tree-traversal: + image: polyglot-tree-traversal + + user_App: + build: + dockerfile: Dockerfile + container_name: polyglot-tree-traversal + + volumes: + - .:/root/polyglot-tree-traversal-example + command: ["metacallcli", "rootNode.py"]