Ramses II commited on
Commit
7950999
1 Parent(s): cb53bb9
Files changed (5) hide show
  1. Dockerfile +1 -14
  2. entrypoint.sh +2 -9
  3. jupyter_config.py +1 -3
  4. nginx.conf +5 -30
  5. requirements.txt +1 -1
Dockerfile CHANGED
@@ -22,25 +22,12 @@ COPY entrypoint.sh /app/entrypoint.sh
22
  # Set the entrypoint script as executable
23
  RUN chmod +x /app/entrypoint.sh
24
 
25
- RUN mkdir -p /var/lib/nginx/body /var/lib/nginx/fastcgi \
26
- /var/lib/nginx/proxy /var/lib/nginx/scgi \
27
- /var/lib/nginx/uwsgi /var/log/nginx \
28
- && chown -R ${NB_UID}:${NB_GID} /var/lib/nginx /var/log/nginx /var/run /run \
29
- && chmod 755 /var/lib/nginx /var/run /run
30
-
31
- # Ensure Nginx has permissions to write to log directory and PID file
32
- RUN touch /var/log/nginx/error.log /var/log/nginx/access.log /run/nginx.pid \
33
- && chown -R ${NB_UID}:${NB_GID} /var/log/nginx /run/nginx.pid
34
-
35
  # Set the permissions for the app directory to the existing user
36
  RUN chown -R ${NB_UID}:${NB_GID} /app
37
 
38
  # Switch back to the original user
39
  USER ${NB_UID}
40
 
41
- # Mount the secret
42
- RUN --mount=type=secret,id=JUPYTER_TOKEN,mode=0444,required=true
43
-
44
  # Set the working directory for the user
45
  WORKDIR /home/${NB_USER}/app
46
 
@@ -56,4 +43,4 @@ ENV JUPYTERLAB_TOKEN=your_secret_token
56
  ENV NGINX_PORT=7860
57
 
58
  # Run the entrypoint script when the container starts
59
- ENTRYPOINT ["/app/entrypoint.sh"]
 
22
  # Set the entrypoint script as executable
23
  RUN chmod +x /app/entrypoint.sh
24
 
 
 
 
 
 
 
 
 
 
 
25
  # Set the permissions for the app directory to the existing user
26
  RUN chown -R ${NB_UID}:${NB_GID} /app
27
 
28
  # Switch back to the original user
29
  USER ${NB_UID}
30
 
 
 
 
31
  # Set the working directory for the user
32
  WORKDIR /home/${NB_USER}/app
33
 
 
43
  ENV NGINX_PORT=7860
44
 
45
  # Run the entrypoint script when the container starts
46
+ ENTRYPOINT ["/app/entrypoint.sh"]
entrypoint.sh CHANGED
@@ -1,14 +1,7 @@
1
  #!/bin/bash
2
 
3
- # Read the JupyterLab token from the HF secret
4
- #JUPYTERLAB_TOKEN=$(cat /run/secrets/JUPYTER_TOKEN)
5
-
6
  # Start JupyterLab in the background
7
- jupyter lab --ip=0.0.0.0 --port=${JUPYTERLAB_PORT} --no-browser --allow-root --NotebookApp.base_url=/jupyter --NotebookApp.token=${JUPYTERLAB_TOKEN} &
8
-
9
- # Ensure the Nginx PID file is writable
10
- touch /tmp/nginx.pid
11
- chmod 644 /tmp/nginx.pid
12
 
13
  # Start Nginx in the foreground
14
- nginx -g "daemon off;" -c /etc/nginx/nginx.conf
 
1
  #!/bin/bash
2
 
 
 
 
3
  # Start JupyterLab in the background
4
+ jupyter lab --port=${JUPYTERLAB_PORT} --no-browser --allow-root &
 
 
 
 
5
 
6
  # Start Nginx in the foreground
7
+ nginx -g "daemon off;"
jupyter_config.py CHANGED
@@ -1,7 +1,5 @@
1
- import os
2
-
3
  c.NotebookApp.ip = '0.0.0.0'
4
  c.NotebookApp.port = 8888
5
  c.NotebookApp.open_browser = False
6
  c.NotebookApp.allow_root = True
7
- c.NotebookApp.token = os.environ.get("JUPYTER_TOKEN")
 
 
 
1
  c.NotebookApp.ip = '0.0.0.0'
2
  c.NotebookApp.port = 8888
3
  c.NotebookApp.open_browser = False
4
  c.NotebookApp.allow_root = True
5
+ c.NotebookApp.token = 'your_secret_token'
nginx.conf CHANGED
@@ -1,42 +1,17 @@
1
- pid /tmp/nginx.pid;
2
- worker_processes 1;
3
-
4
- events {
5
- worker_connections 1024;
6
- }
7
-
8
  http {
9
- include mime.types;
10
- default_type application/octet-stream;
11
-
12
- sendfile on;
13
- keepalive_timeout 65;
14
-
15
  server {
16
- listen 7860;
17
- server_name localhost;
18
 
19
- # Serve static files from /app/public
20
  location / {
21
  root /app/public;
22
- try_files $uri $uri/ =404;
23
  }
24
 
25
- # Proxy JupyterLab to /jupyter/
26
  location /jupyter/ {
27
- proxy_pass http://127.0.0.1:8888;
28
  proxy_set_header Host $host;
29
  proxy_set_header X-Real-IP $remote_addr;
30
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
31
- proxy_set_header X-Forwarded-Proto $scheme;
32
-
33
- # WebSocket support
34
- proxy_http_version 1.1;
35
- proxy_set_header Upgrade $http_upgrade;
36
- proxy_set_header Connection "upgrade";
37
  }
38
-
39
- error_log /tmp/nginx_error.log;
40
- access_log /tmp/nginx_access.log;
41
  }
42
- }
 
 
 
 
 
 
 
 
1
  http {
 
 
 
 
 
 
2
  server {
3
+ listen 7860;
4
+ server_name _;
5
 
 
6
  location / {
7
  root /app/public;
8
+ index index.html;
9
  }
10
 
 
11
  location /jupyter/ {
12
+ proxy_pass http://localhost:8888;
13
  proxy_set_header Host $host;
14
  proxy_set_header X-Real-IP $remote_addr;
 
 
 
 
 
 
 
15
  }
 
 
 
16
  }
17
+ }
requirements.txt CHANGED
@@ -1 +1 @@
1
- jupyterlab==4.0.6
 
1
+ jupyterlab