Ramses II commited on
Commit
ecd62c6
·
1 Parent(s): 3b6b10b
Files changed (2) hide show
  1. Dockerfile +4 -4
  2. entrypoint.sh +10 -3
Dockerfile CHANGED
@@ -27,8 +27,8 @@ COPY entrypoint.sh /app/entrypoint.sh
27
  RUN chmod +x /app/entrypoint.sh
28
 
29
  # Create necessary directories and set permissions
30
- RUN mkdir -p /data /var/log/nginx && \
31
- chown -R ${NB_UID}:${NB_GID} /app /data /var/log/nginx /etc/nginx/nginx.conf && \
32
  chmod 755 /data
33
 
34
  # Switch back to the original user
@@ -37,9 +37,9 @@ USER ${NB_UID}
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
 
27
  RUN chmod +x /app/entrypoint.sh
28
 
29
  # Create necessary directories and set permissions
30
+ RUN mkdir -p /data /var/log/nginx /var/log/pods && \
31
+ chown -R ${NB_UID}:${NB_GID} /app /data /var/log/nginx /var/log/pods /etc/nginx/nginx.conf && \
32
  chmod 755 /data
33
 
34
  # Switch back to the original user
 
37
  # Set the working directory for the user
38
  WORKDIR /data
39
 
40
+ # Mount the secret
41
  RUN --mount=type=secret,id=JUPYTER_TOKEN,mode=0444,required=true \
42
+ cat /run/secrets/JUPYTER_TOKEN
43
 
44
  # Expose the port for Nginx
45
  EXPOSE 7860
entrypoint.sh CHANGED
@@ -17,8 +17,11 @@ if [ ! -w "/data" ]; then
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
 
@@ -41,5 +44,9 @@ jupyter lab --ip=0.0.0.0 --port=${JUPYTERLAB_PORT} --no-browser --allow-root \
41
  --NotebookApp.token=${JUPYTER_TOKEN} \
42
  --notebook-dir=/data &
43
 
 
 
 
 
44
  # Start Nginx in the foreground
45
- 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
+ # Read JupyterLab token from the mounted secret file
21
+ if [ -f "/run/secrets/JUPYTER_TOKEN" ]; then
22
+ export JUPYTER_TOKEN=$(cat /run/secrets/JUPYTER_TOKEN)
23
+ else
24
+ echo "JUPYTER_TOKEN secret not found. Using AUX_TOKEN as fallback."
25
  export JUPYTER_TOKEN=${AUX_TOKEN:-}
26
  fi
27
 
 
44
  --NotebookApp.token=${JUPYTER_TOKEN} \
45
  --notebook-dir=/data &
46
 
47
+ # Ensure the Nginx PID file is writable
48
+ touch /tmp/nginx.pid
49
+ chmod 644 /tmp/nginx.pid
50
+
51
  # Start Nginx in the foreground
52
+ nginx -g "daemon off;" -c /etc/nginx/nginx.conf || handle_error "Failed to start Nginx"