Ramses II commited on
Commit
ea37cb1
·
1 Parent(s): c514065
Files changed (2) hide show
  1. Dockerfile +5 -3
  2. entrypoint.sh +5 -4
Dockerfile CHANGED
@@ -1,4 +1,3 @@
1
- #scipy-nbk
2
  FROM jupyter/scipy-notebook
3
 
4
  # Set the working directory to /data
@@ -54,6 +53,10 @@ RUN touch /var/log/nginx/error.log /var/log/nginx/access.log /run/nginx.pid \
54
  # Create /data directory and set permissions
55
  RUN mkdir -p /data && chown -R ${NB_UID}:${NB_GID} /data
56
 
 
 
 
 
57
  # Switch back to the original user
58
  USER ${NB_UID}
59
 
@@ -69,7 +72,6 @@ EXPOSE 7860
69
  # Set the environment variables
70
  ENV JUPYTERLAB_PORT=8888
71
  ENV NGINX_PORT=7860
72
- ENV JUPYTER_TOKEN=""
73
 
74
  # Run the entrypoint script when the container starts
75
- ENTRYPOINT ["/app/entrypoint.sh"]
 
 
1
  FROM jupyter/scipy-notebook
2
 
3
  # Set the working directory to /data
 
53
  # Create /data directory and set permissions
54
  RUN mkdir -p /data && chown -R ${NB_UID}:${NB_GID} /data
55
 
56
+ # Handle the JUPYTER_TOKEN secret at build time
57
+ RUN --mount=type=secret,id=JUPYTER_TOKEN,mode=0444,required=true \
58
+ echo "JUPYTER_TOKEN=$(cat /run/secrets/JUPYTER_TOKEN)" >> /etc/environment
59
+
60
  # Switch back to the original user
61
  USER ${NB_UID}
62
 
 
72
  # Set the environment variables
73
  ENV JUPYTERLAB_PORT=8888
74
  ENV NGINX_PORT=7860
 
75
 
76
  # Run the entrypoint script when the container starts
77
+ ENTRYPOINT ["/app/entrypoint.sh"]
entrypoint.sh CHANGED
@@ -20,10 +20,11 @@ fi
20
  # Asegurar que el usuario jovyan sea el propietario de /data
21
  chown -R ${NB_UID}:${NB_GID} /data
22
 
23
- # Verificar si el secreto JUPYTER_TOKEN existe y asignarlo a la variable de entorno
24
- if [ -f "/run/secrets/JUPYTER_TOKEN" ]; then
25
- export JUPYTER_TOKEN=$(cat /run/secrets/JUPYTER_TOKEN)
26
- elif [ -z "$JUPYTER_TOKEN" ]; then
 
27
  handle_error "El token de JupyterLab está vacío. Asegúrate de configurar el secreto JUPYTER_TOKEN en la configuración del Space."
28
  fi
29
 
 
20
  # Asegurar que el usuario jovyan sea el propietario de /data
21
  chown -R ${NB_UID}:${NB_GID} /data
22
 
23
+ # Cargar el token de JupyterLab desde el archivo de entorno
24
+ source /etc/environment
25
+
26
+ # Verificar si el token está presente
27
+ if [ -z "$JUPYTER_TOKEN" ]; then
28
  handle_error "El token de JupyterLab está vacío. Asegúrate de configurar el secreto JUPYTER_TOKEN en la configuración del Space."
29
  fi
30