From 06ffe7e7ae3b5b36ab341e830dbbac76243022ca Mon Sep 17 00:00:00 2001 From: Sibam Paul Date: Sun, 23 Feb 2025 08:20:01 +0000 Subject: [PATCH 1/9] Added Docker:- Test docker build in CI workflow --- .github/workflows/ci.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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 From 32720883e7b006d6742b611fe5805e1c5fefb17a Mon Sep 17 00:00:00 2001 From: Sibam Paul Date: Sun, 23 Feb 2025 08:22:08 +0000 Subject: [PATCH 2/9] Added docker ignore for docker build --- .dockerignore | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .dockerignore 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 From 1217bb58718361adca3b4c0d0b11399867be44c8 Mon Sep 17 00:00:00 2001 From: Sibam Paul Date: Sun, 23 Feb 2025 08:23:44 +0000 Subject: [PATCH 3/9] ignore __pycache__ --- .gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 .gitignore 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 From a050baeebef039fef382687ca41a5d9a65b38844 Mon Sep 17 00:00:00 2001 From: Sibam Paul Date: Sun, 23 Feb 2025 08:25:23 +0000 Subject: [PATCH 4/9] Added Docker support --- Dockerfile | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..623007b --- /dev/null +++ b/Dockerfile @@ -0,0 +1,67 @@ +# 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 \ + liburing-dev \ + python3-dev \ + && rm -rf /var/lib/apt/lists/* + +# Installing libtcc from source : C compiler +RUN git clone https://github.com/TinyCC/tinycc.git \ + && cd tinycc \ + && ./configure --prefix=/usr \ + && make \ + && make install \ + && cd .. \ + && rm -rf tinycc + +# 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"] From 7b77400896be46b4dcb83c9781bd87ffce4a7556 Mon Sep 17 00:00:00 2001 From: Sibam Paul Date: Sun, 23 Feb 2025 08:26:17 +0000 Subject: [PATCH 5/9] Added docker-compose file --- docker-compose.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 docker-compose.yml diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..f53dcc3 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,15 @@ +verison: '3.8' +services: + polyglot-tree-traversal: + image: polyglot-tree-traversal + + user_App: + build: + dockerfile: Dockerfile + container_name: polyglot-tree-traversal + environment: + - LOADER_LIBRARY_PATH=/usr/local/lib + - LOADER_SCRIPT_PATH=/root/polyglot-tree-traversal-example + volumes: + - .:/root/polyglot-tree-traversal-example + command: ["metacallcli", "rootNode.py"] From 03691ea9e1cfdc77808d8b19be0627aa27267e80 Mon Sep 17 00:00:00 2001 From: Sibam Paul Date: Sun, 23 Feb 2025 09:54:08 +0000 Subject: [PATCH 6/9] Updating Dockerfile --- Dockerfile | 1 - 1 file changed, 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 623007b..ed67cfa 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,7 +12,6 @@ RUN apt-get update \ git \ npm \ python3 \ - liburing-dev \ python3-dev \ && rm -rf /var/lib/apt/lists/* From aab8aa6c2b033a519a158aec24c357a97077640a Mon Sep 17 00:00:00 2001 From: Sibam Paul Date: Sun, 23 Feb 2025 10:28:42 +0000 Subject: [PATCH 7/9] Added docker testing commands --- Readme.md | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) 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 From e9cc1ed28dabc017d493c43a50874924ab77de07 Mon Sep 17 00:00:00 2001 From: Sibam Paul Date: Sun, 23 Feb 2025 12:44:25 +0000 Subject: [PATCH 8/9] removing tinycc --- Dockerfile | 8 -------- 1 file changed, 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index ed67cfa..48e29ab 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,14 +15,6 @@ RUN apt-get update \ python3-dev \ && rm -rf /var/lib/apt/lists/* -# Installing libtcc from source : C compiler -RUN git clone https://github.com/TinyCC/tinycc.git \ - && cd tinycc \ - && ./configure --prefix=/usr \ - && make \ - && make install \ - && cd .. \ - && rm -rf tinycc # Set working directory WORKDIR /root From 988aa9ae11ce566092d594d97732fb166b0e867f Mon Sep 17 00:00:00 2001 From: Sibam Paul Date: Sun, 23 Feb 2025 13:47:03 +0000 Subject: [PATCH 9/9] Removed environment in docker-compose.yml --- docker-compose.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index f53dcc3..5c74b46 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,9 +7,7 @@ services: build: dockerfile: Dockerfile container_name: polyglot-tree-traversal - environment: - - LOADER_LIBRARY_PATH=/usr/local/lib - - LOADER_SCRIPT_PATH=/root/polyglot-tree-traversal-example + volumes: - .:/root/polyglot-tree-traversal-example command: ["metacallcli", "rootNode.py"]