Dockerfile
 1  # syntax=docker/dockerfile:1
 2  # Copyright 2025 Alibaba Group Holding Ltd.
 3  #
 4  # Licensed under the Apache License, Version 2.0 (the "License");
 5  # you may not use this file except in compliance with the License.
 6  # You may obtain a copy of the License at
 7  #
 8  #     http://www.apache.org/licenses/LICENSE-2.0
 9  #
10  # Unless required by applicable law or agreed to in writing, software
11  # distributed under the License is distributed on an "AS IS" BASIS,
12  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  # See the License for the specific language governing permissions and
14  # limitations under the License.
15  
16  
17  FROM opensandbox/code-interpreter-base:latest
18  
19  ARG TARGETARCH
20  # Prebuilt binary from https://github.com/AkihiroSuda/clone3-workaround/releases/tag/v1.0.0 (amd64 only).
21  # The binary is linked against libseccomp (runtime package libseccomp2 on Ubuntu).
22  RUN set -eux; \
23      if [ "${TARGETARCH}" = "amd64" ]; then \
24          apt-get update && apt-get install -y --no-install-recommends libseccomp2 && rm -rf /var/lib/apt/lists/*; \
25          curl -fsSL -o /usr/local/bin/clone3-workaround \
26              https://github.com/AkihiroSuda/clone3-workaround/releases/download/v1.0.0/clone3-workaround.x86_64; \
27          chmod 755 /usr/local/bin/clone3-workaround; \
28      else \
29          echo "Skipping clone3-workaround: upstream provides amd64/x86_64 binary only (TARGETARCH=${TARGETARCH})"; \
30      fi
31  
32  # Install Python kernels
33  RUN set -euo pipefail \
34      && echo "Setting up ipykernel for Python 3.10, 3.11, 3.12, 3.13, 3.14" \
35      && versions=("3.10" "3.11" "3.12" "3.13" "3.14") \
36      && for version in "${versions[@]}"; do \
37          echo "Setting up ipykernel for Python $version" \
38          && . /opt/opensandbox/code-interpreter-env.sh python $version \
39          && python3 --version \
40          && python3 -m pip install ipykernel jupyter bash_kernel --break-system-packages; \
41      done \
42      && echo "Setting up ipykernel complete"
43  
44  # Install Java kernel
45  RUN set -euo pipefail \
46      && echo "Setting up IJava kernel" \
47      && curl -L https://github.com/SpencerPark/IJava/releases/download/v1.3.0/ijava-1.3.0.zip -o /tmp/ijava.zip \
48      && mkdir -p /opt/ijava \
49      && unzip -o /tmp/ijava.zip -d /opt/ijava \
50      && rm -rf /tmp/ijava.zip \
51      && echo "Setting up IJava kernel done"
52  
53  # Install tslab for Node.js versions
54  RUN set -euo pipefail \
55      && echo "Setting up tslab kernel" \
56      && versions=("18" "20" "22") \
57      && for version in "${versions[@]}"; do \
58          echo "Setting up tslab for Node $version" \
59          && . /opt/opensandbox/code-interpreter-env.sh node $version \
60          && node --version \
61          && npm --version \
62          && npm install -g tslab; \
63      done \
64      && echo "Setting up tslab kernel done"
65  
66  # Install Go tooling for gonb
67  RUN set -euo pipefail \
68      && echo "Setting up gonb" \
69      && versions=("1.25" "1.24" "1.23") \
70      && for version in "${versions[@]}"; do \
71          echo "Setting up gonb for Go $version" \
72          && . /opt/opensandbox/code-interpreter-env.sh go $version \
73          && go version \
74          && go install github.com/janpfeifer/gonb@latest \
75          && go install golang.org/x/tools/cmd/goimports@latest \
76          && go install golang.org/x/tools/gopls@latest; \
77      done \
78      && echo "Setting up gonb done"
79  
80  ENV JUPYTER_HOST=http://127.0.0.1:44771 \
81      JUPYTER_PORT=44771 \
82      JUPYTER_TOKEN=opensandboxcodeinterpreterjupyter \
83      PYTHON_VERSION=3.14 \
84      NODE_VERSION=22 \
85      GO_VERSION=1.25 \
86      JAVA_VERSION=21
87  
88  COPY scripts/code-interpreter.sh /opt/opensandbox/code-interpreter.sh
89  COPY scripts/jupyter_notebook_config.py /root/.jupyter/
90  RUN chmod +x /opt/opensandbox/code-interpreter.sh
91  
92  WORKDIR /workspace
93  ENTRYPOINT ["/opt/opensandbox/code-interpreter.sh"]