Skip to content

Commit 8ad22ef

Browse files
committed
wip
1 parent d4f1d0b commit 8ad22ef

File tree

5 files changed

+41
-39
lines changed

5 files changed

+41
-39
lines changed

template/Dockerfile

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@ FROM python:3.10.14
33
RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y --no-install-recommends \
44
build-essential curl git util-linux jq sudo nodejs npm fonts-noto-cjk
55

6+
RUN mkdir -p /home/user/.jupyter /home/user/.ipython /home/user/.server
7+
68
ENV PIP_DEFAULT_TIMEOUT=100 \
79
PIP_DISABLE_PIP_VERSION_CHECK=1 \
810
PIP_NO_CACHE_DIR=1 \
9-
JUPYTER_CONFIG_PATH="/root/.jupyter" \
10-
IPYTHON_CONFIG_PATH="/root/.ipython" \
11-
SERVER_PATH="/root/.server" \
11+
JUPYTER_CONFIG_PATH="/home/user/.jupyter" \
12+
IPYTHON_CONFIG_PATH="/home/user/.ipython" \
13+
SERVER_PATH="/home/user/.server" \
1214
R_VERSION=4.4.2
1315

1416
ENV R_HOME=/opt/R/${R_VERSION} \
@@ -19,9 +21,9 @@ COPY ./requirements.txt requirements.txt
1921
RUN pip install --no-cache-dir -r requirements.txt && ipython kernel install --name "python3" --user
2022

2123
# R Kernel
22-
RUN curl -O https://cdn.rstudio.com/r/debian-12/pkgs/r-${R_VERSION}_1_amd64.deb && sudo apt-get update && sudo apt-get install -y ./r-${R_VERSION}_1_amd64.deb && ln -s ${R_HOME}/bin/R /usr/bin/R
23-
RUN R -e "install.packages('IRkernel', repos='https://cloud.r-project.org')"
24-
RUN R -e "IRkernel::installspec(user = FALSE, name = 'r', displayname = 'R')"
24+
# RUN curl -O https://cdn.rstudio.com/r/debian-12/pkgs/r-${R_VERSION}_1_amd64.deb && sudo apt-get update && sudo apt-get install -y ./r-${R_VERSION}_1_amd64.deb && ln -s ${R_HOME}/bin/R /usr/bin/R
25+
# RUN R -e "install.packages('IRkernel', repos='https://cloud.r-project.org')"
26+
# RUN R -e "IRkernel::installspec(user = FALSE, name = 'r', displayname = 'R')"
2527

2628
# Javascript Kernel
2729
RUN npm install -g node-gyp
@@ -32,7 +34,7 @@ RUN ijsinstall --install=global
3234
COPY --from=denoland/deno:bin-2.0.4 /deno /usr/bin/deno
3335
RUN chmod +x /usr/bin/deno
3436
RUN deno jupyter --unstable --install
35-
COPY ./deno.json /root/.local/share/jupyter/kernels/deno/kernel.json
37+
COPY ./deno.json /home/user/.local/share/jupyter/kernels/deno/kernel.json
3638

3739
# Bash Kernel
3840
RUN pip install bash_kernel
@@ -42,13 +44,12 @@ RUN python -m bash_kernel.install
4244
RUN python -m venv $SERVER_PATH/.venv
4345

4446
# Copy server and its requirements
45-
RUN mkdir -p $SERVER_PATH/
4647
COPY ./server/requirements.txt $SERVER_PATH
4748
RUN $SERVER_PATH/.venv/bin/pip install --no-cache-dir -r $SERVER_PATH/requirements.txt
4849
COPY ./server $SERVER_PATH
4950

5051
# Copy matplotlibrc
51-
COPY matplotlibrc /root/.config/matplotlib/.matplotlibrc
52+
COPY matplotlibrc /home/user/.config/matplotlib/.matplotlibrc
5253

5354
# Copy Jupyter configuration
5455
COPY ./start-up.sh $JUPYTER_CONFIG_PATH/

template/e2b.toml

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
# This is a config for E2B sandbox template.
2-
# You can use template ID (nlhz8vlwyupq845jsdg9) or template name (code-interpreter-v1) to create a sandbox:
2+
# You can use template ID (8cvk102nkxqyd5l3kelv) to create a sandbox:
33

44
# Python SDK
55
# from e2b import Sandbox, AsyncSandbox
6-
# sandbox = Sandbox("code-interpreter-v1") # Sync sandbox
7-
# sandbox = await AsyncSandbox.create("code-interpreter-v1") # Async sandbox
6+
# sandbox = Sandbox("8cvk102nkxqyd5l3kelv") # Sync sandbox
7+
# sandbox = await AsyncSandbox.create("8cvk102nkxqyd5l3kelv") # Async sandbox
88

99
# JS SDK
1010
# import { Sandbox } from 'e2b'
11-
# const sandbox = await Sandbox.create('code-interpreter-v1')
11+
# const sandbox = await Sandbox.create('8cvk102nkxqyd5l3kelv')
1212

13-
team_id = "460355b3-4f64-48f9-9a16-4442817f79f5"
13+
team_id = "400a4584-3d22-4b70-82ee-0bc6cce4aaa5"
1414
memory_mb = 1_024
15-
start_cmd = "/root/.jupyter/start-up.sh"
16-
dockerfile = "e2b.Dockerfile"
17-
template_name = "code-interpreter-v1"
18-
template_id = "nlhz8vlwyupq845jsdg9"
15+
start_cmd = "/home/user/.jupyter/start-up.sh"
16+
dockerfile = "Dockerfile"
17+
template_id = "8cvk102nkxqyd5l3kelv"

template/server/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ async def lifespan(app: FastAPI):
3434
global client
3535
client = httpx.AsyncClient()
3636

37-
with open("/root/.jupyter/kernel_id") as file:
37+
with open("/home/user/.jupyter/kernel_id") as file:
3838
default_context_id = file.read().strip()
3939

4040
default_ws = ContextWebSocket(

template/start-up.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ function start_jupyter_server() {
2020
exit 1
2121
fi
2222

23-
sudo mkdir -p /root/.jupyter
23+
mkdir -p /home/user/.jupyter
2424
kernel_id=$(echo "${response}" | jq -r '.kernel.id')
25-
sudo echo "${kernel_id}" | sudo tee /root/.jupyter/kernel_id >/dev/null
26-
sudo echo "${response}" | sudo tee /root/.jupyter/.session_info >/dev/null
25+
echo "${kernel_id}" > /home/user/.jupyter/kernel_id
26+
echo "${response}" > /home/user/.jupyter/.session_info
2727

28-
cd /root/.server/
29-
/root/.server/.venv/bin/uvicorn main:app --host 0.0.0.0 --port 49999 --workers 1 --no-access-log --no-use-colors
28+
cd /home/user/.server/
29+
/home/user/.server/.venv/bin/uvicorn main:app --host 0.0.0.0 --port 49999 --workers 1 --no-access-log --no-use-colors
3030
}
3131

3232
echo "Starting Code Interpreter server..."
3333
start_jupyter_server &
34-
MATPLOTLIBRC=/root/.config/matplotlib/.matplotlibrc jupyter server --IdentityProvider.token="" >/dev/null 2>&1
34+
MATPLOTLIBRC=/home/user/.config/matplotlib/.matplotlibrc jupyter server --IdentityProvider.token="" >/dev/null 2>&1

template/test.Dockerfile

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,17 @@ ENV PATH="${JAVA_HOME}/bin:${PATH}"
77
RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y --no-install-recommends \
88
build-essential curl git util-linux jq sudo nodejs npm fonts-noto-cjk
99

10+
RUN mkdir -p /home/user/.jupyter /home/user/.ipython /home/user/.server
11+
1012
ENV PIP_DEFAULT_TIMEOUT=100 \
1113
PIP_DISABLE_PIP_VERSION_CHECK=1 \
1214
PIP_NO_CACHE_DIR=1 \
13-
JUPYTER_CONFIG_PATH="/root/.jupyter" \
14-
IPYTHON_CONFIG_PATH="/root/.ipython" \
15-
SERVER_PATH="/root/.server"
15+
JUPYTER_CONFIG_PATH="/home/user/.jupyter" \
16+
IPYTHON_CONFIG_PATH="/home/user/.ipython" \
17+
SERVER_PATH="/home/user/.server"
1618

1719
# Install Jupyter
18-
COPY ./template/requirements.txt requirements.txt
20+
COPY ./requirements.txt requirements.txt
1921
RUN pip install --no-cache-dir -r requirements.txt && ipython kernel install --name "python3" --user
2022

2123
# Javascript Kernel
@@ -27,34 +29,34 @@ RUN ijsinstall --install=global
2729
COPY --from=denoland/deno:bin-2.0.4 /deno /usr/bin/deno
2830
RUN chmod +x /usr/bin/deno
2931
RUN deno jupyter --unstable --install
30-
COPY ./template/deno.json /root/.local/share/jupyter/kernels/deno/kernel.json
32+
COPY ./deno.json /home/user/.local/share/jupyter/kernels/deno/kernel.json
3133

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

3537
# Copy server and its requirements
3638
RUN mkdir -p $SERVER_PATH/
37-
COPY ./template/server/requirements.txt $SERVER_PATH
39+
COPY ./server/requirements.txt $SERVER_PATH
3840
RUN $SERVER_PATH/.venv/bin/pip install --no-cache-dir -r $SERVER_PATH/requirements.txt
39-
COPY ./template/server $SERVER_PATH
41+
COPY ./server $SERVER_PATH
4042

4143
# Copy matplotlibrc
42-
COPY ./template/matplotlibrc /root/.config/matplotlib/matplotlibrc
44+
COPY ./matplotlibrc /home/user/.config/matplotlib/matplotlibrc
4345

4446
# Copy Jupyter configuration
45-
COPY ./template/start-up.sh $JUPYTER_CONFIG_PATH/
47+
COPY ./start-up.sh $JUPYTER_CONFIG_PATH/
4648
RUN chmod +x $JUPYTER_CONFIG_PATH/start-up.sh
4749

48-
COPY ./template/jupyter_server_config.py $JUPYTER_CONFIG_PATH/
50+
COPY ./jupyter_server_config.py $JUPYTER_CONFIG_PATH/
4951

5052
RUN mkdir -p $IPYTHON_CONFIG_PATH/profile_default
51-
COPY ./template/ipython_kernel_config.py $IPYTHON_CONFIG_PATH/profile_default/
53+
COPY ./ipython_kernel_config.py $IPYTHON_CONFIG_PATH/profile_default/
5254

5355
RUN mkdir -p $IPYTHON_CONFIG_PATH/profile_default/startup
54-
COPY ./template/startup_scripts/* $IPYTHON_CONFIG_PATH/profile_default/startup
56+
COPY ./startup_scripts/* $IPYTHON_CONFIG_PATH/profile_default/startup
5557

5658
# Setup entrypoint for local development
5759
WORKDIR /home/user
58-
COPY ./chart_data_extractor ./chart_data_extractor
59-
RUN pip install -e ./chart_data_extractor
60+
# COPY ./chart_data_extractor ./chart_data_extractor
61+
# RUN pip install -e ./chart_data_extractor
6062
ENTRYPOINT $JUPYTER_CONFIG_PATH/start-up.sh

0 commit comments

Comments
 (0)