Ramses II commited on
Commit
3b6b10b
1 Parent(s): c0616b4
Files changed (4) hide show
  1. .DS_Store +0 -0
  2. Dockerfile +4 -3
  3. entrypoint.sh +5 -3
  4. jupyter_config.py +1 -1
.DS_Store CHANGED
Binary files a/.DS_Store and b/.DS_Store differ
 
Dockerfile CHANGED
@@ -37,11 +37,12 @@ USER ${NB_UID}
37
  # Set the working directory for the user
38
  WORKDIR /data
39
 
 
 
 
 
40
  # Expose the port for Nginx
41
  EXPOSE 7860
42
 
43
- # Set the environment variables
44
- ENV JUPYTERLAB_PORT=8888
45
-
46
  # Run the entrypoint script when the container starts
47
  ENTRYPOINT ["/app/entrypoint.sh"]
 
37
  # Set the working directory for the user
38
  WORKDIR /data
39
 
40
+ # Mount the secret and expose it as an environment variable
41
+ RUN --mount=type=secret,id=JUPYTER_TOKEN,mode=0444,required=true \
42
+ export JUPYTER_TOKEN=$(cat /run/secrets/JUPYTER_TOKEN)
43
+
44
  # Expose the port for Nginx
45
  EXPOSE 7860
46
 
 
 
 
47
  # Run the entrypoint script when the container starts
48
  ENTRYPOINT ["/app/entrypoint.sh"]
entrypoint.sh CHANGED
@@ -17,8 +17,10 @@ if [ ! -w "/data" ]; then
17
  echo "Warning: No write permissions for /data. Some data may not be persistent."
18
  fi
19
 
20
- # Read JupyterLab token from HF secret
21
- JUPYTER_TOKEN=$(cat /run/secrets/JUPYTER_TOKEN)
 
 
22
 
23
  # Verify if the token is empty
24
  if [ -z "$JUPYTER_TOKEN" ]; then
@@ -40,4 +42,4 @@ jupyter lab --ip=0.0.0.0 --port=${JUPYTERLAB_PORT} --no-browser --allow-root \
40
  --notebook-dir=/data &
41
 
42
  # Start Nginx in the foreground
43
- nginx -g "daemon off;" || handle_error "Failed to start Nginx"
 
17
  echo "Warning: No write permissions for /data. Some data may not be persistent."
18
  fi
19
 
20
+ # Use the AUX_TOKEN environment variable if JUPYTER_TOKEN is not set
21
+ if [ -z "$JUPYTER_TOKEN" ]; then
22
+ export JUPYTER_TOKEN=${AUX_TOKEN:-}
23
+ fi
24
 
25
  # Verify if the token is empty
26
  if [ -z "$JUPYTER_TOKEN" ]; then
 
42
  --notebook-dir=/data &
43
 
44
  # Start Nginx in the foreground
45
+ nginx -g "daemon off;" || handle_error "Failed to start Nginx"
jupyter_config.py CHANGED
@@ -7,5 +7,5 @@ c.NotebookApp.port = 8888
7
  c.NotebookApp.open_browser = False
8
  c.NotebookApp.notebook_dir = '/data'
9
  c.NotebookApp.allow_root = True
10
- c.NotebookApp.token = os.environ.get('JUPYTER_TOKEN', '')
11
  c.NotebookApp.base_url = '/jupyter'
 
7
  c.NotebookApp.open_browser = False
8
  c.NotebookApp.notebook_dir = '/data'
9
  c.NotebookApp.allow_root = True
10
+ c.NotebookApp.token = os.environ.get('JUPYTER_TOKEN')
11
  c.NotebookApp.base_url = '/jupyter'