diff --git a/integration/Dockerfile-ErgoAIStudio b/integration/Dockerfile-ErgoAIStudio new file mode 100644 index 0000000..4a15adf --- /dev/null +++ b/integration/Dockerfile-ErgoAIStudio @@ -0,0 +1,128 @@ +FROM amazoncorretto:8 + +# Set environment variables +ENV JAVA_HOME=/usr/lib/jvm/java-1.8.0-amazon-corretto +ENV XSB_DIR=/opt/ergoai/XSB +ENV PATH="$XSB_DIR/bin:$JAVA_HOME/bin:$PATH" +ENV CLASSPATH=$JAVA_HOME/lib + +# Install build dependencies and optional packages for Amazon Linux +RUN yum update -y && yum install -y \ + git \ + make \ + gcc \ + gcc-c++ \ + glibc-devel \ + curl-devel \ + pcre-devel \ + unixODBC-devel \ + autoconf \ + automake \ + libtool \ + python3 \ + python3-pip \ + perl \ + wget \ + tar \ + which \ + mysql \ + mysql-devel \ + xorg-x11-server-Xorg \ + xorg-x11-xauth \ + xorg-x11-apps \ + libX11 \ + libX11-devel \ + libXau \ + libXau-devel \ + libxcb \ + libxcb-devel \ + libXdmcp \ + libXdmcp-devel \ + libXext \ + libXext-devel \ + libXi \ + libXi-devel \ + libXrender \ + libXrender-devel \ + libXrandr \ + libXrandr-devel \ + libXtst \ + libXtst-devel \ + libXt-devel \ + libXft-devel \ + && yum clean all + +# Install Apache Ant +RUN wget https://archive.apache.org/dist/ant/binaries/apache-ant-1.10.14-bin.tar.gz && \ + tar -xzf apache-ant-1.10.14-bin.tar.gz -C /opt && \ + ln -s /opt/apache-ant-1.10.14/bin/ant /usr/bin/ant && \ + rm apache-ant-1.10.14-bin.tar.gz + +# Create working directory +WORKDIR /opt/ergoai + +# 1. Build XSB +RUN git clone https://git.code.sf.net/p/xsb/code xsb_repo && \ + mv xsb_repo/XSB . && \ + rm -rf xsb_repo && \ + cd XSB/build && \ + ./configure && \ + ./makexsb + +# 2. Create proper directory structure and clone repos +WORKDIR /opt/ergoai +RUN mkdir -p ERGOAI + +# Clone repositories +RUN git clone https://github.com/ErgoAI/ErgoEngine.git && \ + git clone https://github.com/ErgoAI/Studio_fidji.git + +# Set up proper directory structure according to documentation +RUN mv ErgoEngine ERGOAI/ && \ + mv Studio_fidji ERGOAI/ && \ + # Create symbolic link to XSB inside ERGOAI folder + cd ERGOAI && \ + ln -s /opt/ergoai/XSB XSB + +# 3. Build the ERGOAI Engine +WORKDIR /opt/ergoai/ERGOAI/ErgoEngine/ErgoAI +RUN sed -i 's/test -f docs\/Makefile && cd docs && make || echo "" > \/dev\/null/echo "Skipping docs generation"/' Makefile && \ + # Modify interprolog timeout + sed -i 's/engineTimeout\s*=\s*8000/engineTimeout = 30000/' ergo_lib/ergo2java/interprolog.P || echo "Couldn't modify interprolog timeout" && \ + make clean && \ + ./makeergo all /opt/ergoai/XSB/bin/xsb || true + +# 4. Make sure the paths file exists and has the right content +RUN echo "/opt/ergoai/XSB/bin/xsb" > .ergo_paths && \ + chmod +x runergo + +# 5. Build Studio from the correct directory +WORKDIR /opt/ergoai/ERGOAI +RUN ErgoEngine/ErgoAI/Studio_scripts/buildErgoStudio.sh || true + +# 6. Create a wrapper script that points to the correct directory +WORKDIR /opt/ergoai +RUN echo '#!/bin/bash' > run_ergo.sh && \ + echo 'export ERGO_DIR=/opt/ergoai/ERGOAI/ErgoEngine/ErgoAI' >> run_ergo.sh && \ + echo 'export JAVA_HOME=/usr/lib/jvm/java-1.8.0-amazon-corretto' >> run_ergo.sh && \ + echo 'export CLASSPATH=$JAVA_HOME/lib' >> run_ergo.sh && \ + echo 'export PATH=$ERGO_DIR/bin:$JAVA_HOME/bin:$PATH' >> run_ergo.sh && \ + echo 'cd $ERGO_DIR' >> run_ergo.sh && \ + echo 'if [ "$1" = "shell" ]; then' >> run_ergo.sh && \ + echo ' exec ./runergo "${@:2}"' >> run_ergo.sh && \ + echo 'elif [ -z "$1" ]; then' >> run_ergo.sh && \ + echo ' exec ./runergo' >> run_ergo.sh && \ + echo 'else' >> run_ergo.sh && \ + echo ' exec "$@"' >> run_ergo.sh && \ + echo 'fi' >> run_ergo.sh && \ + chmod +x run_ergo.sh + +# 7. Add a convenience script to run ErgoAI Studio +RUN echo '#!/bin/bash' > run_studio.sh && \ + echo 'cd /opt/ergoai/ERGOAI' >> run_studio.sh && \ + echo './runErgoAI.sh "$@"' >> run_studio.sh && \ + chmod +x run_studio.sh + +# Set entry point +WORKDIR /opt/ergoai +ENTRYPOINT ["/opt/ergoai/run_studio.sh"] diff --git a/profile/README.md b/profile/README.md index dcdce4f..e81bcf0 100644 --- a/profile/README.md +++ b/profile/README.md @@ -9,6 +9,7 @@ * [Download and Installation](#download-and-installation) - [Installing ErgoAI via an official release](#installing-ergoai-via-an-official-release) - [Installing ErgoAI from the sources](#installing-ergoai-from-the-sources) + - [Installing ErgoAI from Dockerfile](#installing-ergoai-from-dockerfile) - [Uninstallation](#uninstallation) * [Reporting Bugs](#reporting-bugs) * [Bibliography](#bibliography) @@ -175,6 +176,45 @@ Please subscribe to [Ergo and XSB Users Forum](https://groups.google.com/a/coherentknowledge.com/g/ergoai-xsb-forum) and, if you like ErgoAI, [give us a star](https://github.com/ErgoAI/ErgoEngine/stargazers). +#### Installing ErgoAI from Dockerfile + +Under `integration/` you may find `Dockerfile-ErgoAIStudio`. This Dockerfile has the following features and assumptions: + +* Base image is Amazon Correto 8, which is a flavor of openjdk 8 optimized for AWS EC2 but can be used anywhere + +* Configures X11 for within the Docker container + +* Pulls and builds the latest from ErgoEngine and the Ergo Studio `Studio_fidji` repos + +* Builds convenience scripts for running the studio or just the engine on its own + +Please note: + +* This Dockerfile is built under the assumption you are deploying on a x86 or amd64 based architecture. It has not been tested on arm64 chips, so please expect potential bugs if running on this architecture. + +* If you are deploying this on a remote server and are running an X11 desktop distribution to access the GUI served on the remote server, you will need to use `ssh -X` or `ssh -Y` when connecting to the server from your local machine. This is necessary for the transfer protocols. + +Those who want to use the Dockerfile and build ErgoEngine + ErgoAI Studio and access the GUI via X11 can do so via the following: + +* Place Dockerfile-ErgoAIStudio on your local system. + +* For Ubuntu servers install: `sudo apt-get install -y xauth x11-apps`. For yum-based servers: `sudo yum install -y xorg-x11-xauth xorg-x11-apps` + +* Run: `docker build . -f Dockerfile-ErgoAIStudio -t ergoai:latest` (You can rename the tag to whatever you would like.) + +* Establish env variable for XAuthority: `export XAUTHORITY=$HOME/.Xauthority` + +* Establish DISPLAY variable for X11: `export DISPLAY=localhost:10.0`. Note it does not need to exclusively be `10.0`. + +* Build the image: `docker build . -f Dockerfile-ErgoAIStudio -t ergoai:latest` Note the tag does not need to be `ergoai:latest`. + +* Run the container: `docker run -it --rm -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix -v $HOME/.Xauthority:/root/.Xauthority:ro --network=host ergoai:latest` + +Completing these steps will then launch the ErgoAI Studio in your local machines X11 application. + +Important consideration: If you are using XQuartz on a MacOS system there is a known bug where alpha channels are ignored, causing the GUI to appear all black. To avoid this issue all you need to do is simply increase your computer's zoom level one step. See [here](https://github.com/XQuartz/XQuartz/issues/31#issuecomment-2650339982). + + #### Uninstallation If one installed an official release of ErgoAI and a new release comes out, installing the new release doesn't necessarily uninstalls the old (for example, one might want to keep a stable old release and to play with a new pre-release).