Skip to content

Added support for Ruby #106

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 2 commits into
base: main
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 .changeset/shy-months-beg.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@e2b/code-interpreter-template': patch
---

added Ruby support
17 changes: 15 additions & 2 deletions template/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ ENV PIP_DEFAULT_TIMEOUT=100 \
JUPYTER_CONFIG_PATH="/root/.jupyter" \
IPYTHON_CONFIG_PATH="/root/.ipython" \
SERVER_PATH="/root/.server" \
R_VERSION=4.4.2
R_VERSION=4.4.2 \
RUBY_VERSION=3.4.3

ENV R_HOME=/opt/R/${R_VERSION} \
JAVA_HOME=/opt/java/openjdk
JAVA_HOME=/opt/java/openjdk \
RUBY_HOME=/opt/ruby/${RUBY_VERSION}

# Install Jupyter
COPY ./requirements.txt requirements.txt
Expand Down Expand Up @@ -78,5 +80,16 @@ RUN wget https://github.com/SpencerPark/IJava/releases/download/v1.3.0/ijava-1.3
unzip ijava-1.3.0.zip && \
python install.py --sys-prefix

# Install Ruby using ruby-build
RUN git clone https://github.com/rbenv/ruby-build.git ~/.ruby-build
RUN ~/.ruby-build/bin/ruby-build ${RUBY_VERSION} ${RUBY_HOME}
ENV PATH="${RUBY_HOME}/bin:${PATH}"
ENV PATH="/root/.local/share/gem/ruby/${RUBY_VERSION%.*}.0/bin:${PATH}"

# Install IRuby
RUN gem install --user-install rubygems-requirements-system && \
gem install --user-install iruby && \
iruby register --force

# Setup entrypoint for local development
ENTRYPOINT $JUPYTER_CONFIG_PATH/start-up.sh
3 changes: 3 additions & 0 deletions template/server/contexts.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ def normalize_language(language: Optional[str]) -> str:
if language == "ts":
return "typescript"

if language == "ruby" or language == "rb":
return "ruby3"

return language


Expand Down
16 changes: 15 additions & 1 deletion template/test.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ ENV PIP_DEFAULT_TIMEOUT=100 \
PIP_NO_CACHE_DIR=1 \
JUPYTER_CONFIG_PATH="/root/.jupyter" \
IPYTHON_CONFIG_PATH="/root/.ipython" \
SERVER_PATH="/root/.server"
SERVER_PATH="/root/.server" \
RUBY_VERSION=3.4.3

ENV RUBY_HOME=/opt/ruby/${RUBY_VERSION}

# Install Jupyter
COPY ./template/requirements.txt requirements.txt
Expand All @@ -36,6 +39,17 @@ RUN chmod +x /usr/bin/deno
RUN deno jupyter --unstable --install
COPY ./template/deno.json /root/.local/share/jupyter/kernels/deno/kernel.json

# Install Ruby using ruby-build
RUN git clone https://github.com/rbenv/ruby-build.git ~/.ruby-build
RUN ~/.ruby-build/bin/ruby-build ${RUBY_VERSION} ${RUBY_HOME}
ENV PATH="${RUBY_HOME}/bin:${PATH}"
ENV PATH="/root/.local/share/gem/ruby/${RUBY_VERSION%.*}.0/bin:${PATH}"

# Install IRuby
RUN gem install --user-install rubygems-requirements-system && \
gem install --user-install iruby && \
iruby register --force

# Create separate virtual environment for server
RUN python -m venv $SERVER_PATH/.venv

Expand Down
Loading