epaps commited on
Commit
4bb29a4
·
1 Parent(s): d87c106
Files changed (3) hide show
  1. Dockerfile +13 -7
  2. jupyter_server_config.py +34 -0
  3. start.sh +3 -7
Dockerfile CHANGED
@@ -9,12 +9,21 @@ RUN mkdir -p /var/lib/apt/lists/partial && \
9
 
10
  WORKDIR /work
11
 
12
- # Your conda env file is in binder/environment.yml inside the repo
13
  COPY binder/environment.yml /tmp/environment.yml
14
  RUN micromamba env create -f /tmp/environment.yml && micromamba clean -a -y
15
 
16
- # Build StochasticCIL
17
- RUN git clone https://github.com/epapoutsellis/Split-Skip-and-Play.git && git clone https://github.com/epapoutsellis/StochasticCIL.git && \
 
 
 
 
 
 
 
 
 
18
  cd StochasticCIL && \
19
  git fetch --all --tags && \
20
  git checkout svrg && \
@@ -33,8 +42,5 @@ RUN git clone https://github.com/epapoutsellis/Split-Skip-and-Play.git && git cl
33
  make -j"$(nproc)" && \
34
  make install
35
 
36
- COPY start.sh /start.sh
37
- RUN chmod +x /start.sh
38
-
39
  EXPOSE 7860
40
- CMD ["/start.sh"]
 
9
 
10
  WORKDIR /work
11
 
12
+ # 1) Create env first (better cache)
13
  COPY binder/environment.yml /tmp/environment.yml
14
  RUN micromamba env create -f /tmp/environment.yml && micromamba clean -a -y
15
 
16
+ # 2) Copy the WHOLE Space repo into the image
17
+ # This is what makes notebooks/scripts appear in JupyterLab
18
+ COPY . /work
19
+
20
+ # 3) Install Jupyter config + start script
21
+ RUN mkdir -p /etc/jupyter && \
22
+ cp /work/jupyter_server_config.py /etc/jupyter/jupyter_server_config.py && \
23
+ chmod +x /work/start.sh
24
+
25
+ # 4) (Optional) Build StochasticCIL (keep if you need it in the Space)
26
+ RUN git clone https://github.com/epapoutsellis/StochasticCIL.git && \
27
  cd StochasticCIL && \
28
  git fetch --all --tags && \
29
  git checkout svrg && \
 
42
  make -j"$(nproc)" && \
43
  make install
44
 
 
 
 
45
  EXPOSE 7860
46
+ CMD ["/work/start.sh"]
jupyter_server_config.py ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+
3
+ PORT = int(os.environ.get("PORT", "7860"))
4
+ TOKEN = os.environ.get("JUPYTER_TOKEN", "")
5
+
6
+ c.ServerApp.ip = "0.0.0.0"
7
+ c.ServerApp.port = PORT
8
+ c.ServerApp.open_browser = False
9
+ c.ServerApp.allow_root = True
10
+ c.ServerApp.allow_remote_access = True
11
+
12
+ # Show your repo contents
13
+ c.ServerApp.root_dir = "/work"
14
+
15
+ # Make the Space load JupyterLab directly (instead of a blank / page)
16
+ # Change this path to your repo folder name if needed.
17
+ c.ServerApp.default_url = "/lab/tree/Split-Skip-and-Play"
18
+
19
+ # Allow embedding in the Hugging Face Space page iframe
20
+ c.ServerApp.tornado_settings = {
21
+ "headers": {
22
+ "Content-Security-Policy": "frame-ancestors *"
23
+ }
24
+ }
25
+
26
+ # Cookies in an iframe need SameSite=None; Secure
27
+ c.ServerApp.cookie_options = {"SameSite": "None", "Secure": True}
28
+
29
+ # In iframe contexts, browsers sometimes drop the xsrf cookie; this avoids kernel-start failures.
30
+ # IMPORTANT: keep a token (JUPYTER_TOKEN) if your Space is public.
31
+ c.ServerApp.disable_check_xsrf = True
32
+
33
+ # Require token if provided (set this in Space Settings -> Secrets)
34
+ c.ServerApp.token = TOKEN
start.sh CHANGED
@@ -1,12 +1,8 @@
1
  #!/usr/bin/env bash
2
  set -euo pipefail
3
 
4
- TOKEN="${JUPYTER_TOKEN:-}"
 
5
 
6
  exec micromamba run -n ssp jupyter lab \
7
- --allow-root \
8
- --ip=0.0.0.0 --port=7860 \
9
- --no-browser \
10
- --ServerApp.allow_remote_access=True \
11
- --ServerApp.root_dir=/work \
12
- --IdentityProvider.token="${TOKEN}"
 
1
  #!/usr/bin/env bash
2
  set -euo pipefail
3
 
4
+ # HF sets PORT; fallback to 7860
5
+ export PORT="${PORT:-7860}"
6
 
7
  exec micromamba run -n ssp jupyter lab \
8
+ --config=/etc/jupyter/jupyter_server_config.py