FROM jupyter/scipy-notebook:latest # Set the working directory to /app WORKDIR /app # Copy the requirements file and install Python dependencies COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # Copy static files COPY public /app/public # Switch to root user to install system packages and set permissions USER root # Install necessary dependencies RUN apt-get update && apt-get install -y \ nginx \ && apt-get clean && rm -rf /var/lib/apt/lists/* # Copy the configuration files and entrypoint script COPY jupyter_config.py /etc/jupyter/jupyter_config.py COPY nginx.conf /etc/nginx/nginx.conf COPY entrypoint.sh /app/entrypoint.sh # Set the entrypoint script as executable RUN chmod +x /app/entrypoint.sh # Create necessary directories and set permissions RUN mkdir -p /data /var/log/nginx && \ chown -R ${NB_UID}:${NB_GID} /app /data /var/log/nginx /etc/nginx/nginx.conf && \ chmod 755 /data # Switch back to the original user USER ${NB_UID} # Set the working directory for the user WORKDIR /data # Mount the secret and expose it as an environment variable RUN --mount=type=secret,id=JUPYTER_TOKEN,mode=0444,required=true \ export JUPYTER_TOKEN=$(cat /run/secrets/JUPYTER_TOKEN) # Expose the port for Nginx EXPOSE 7860 # Run the entrypoint script when the container starts ENTRYPOINT ["/app/entrypoint.sh"]