Skip to content

feat : Docker Support Added fix (issue-#2) #3

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

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.git
__pycache__
node_modules
build
core
7 changes: 6 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__pycache__
58 changes: 58 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
15 changes: 14 additions & 1 deletion Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
- 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
```
13 changes: 13 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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"]