BinaryONe commited on
Commit
07f0f49
·
1 Parent(s): 27ae252

Initial Commit

Browse files
Files changed (7) hide show
  1. Dockerfile +107 -0
  2. login.html +68 -0
  3. on_startup.sh +5 -0
  4. packages.txt +5 -0
  5. requirements.txt +42 -0
  6. requirements_org.txt +3 -0
  7. start_server.sh +24 -0
Dockerfile ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM nvidia/cuda:12.5.1-cudnn-devel-ubuntu20.04
2
+
3
+ ENV DEBIAN_FRONTEND=noninteractive \
4
+ TZ=Asia/Kolkata
5
+
6
+ # Remove any third-party apt sources to avoid issues with expiring keys.
7
+ # Install some basic utilities
8
+ RUN rm -f /etc/apt/sources.list.d/*.list && \
9
+ apt-get update && apt-get install -y --no-install-recommends \
10
+ curl \
11
+ ca-certificates \
12
+ sudo \
13
+ git \
14
+ wget \
15
+ procps \
16
+ git-lfs \
17
+ zip \
18
+ unzip \
19
+ htop \
20
+ vim \
21
+ nano \
22
+ bzip2 \
23
+ libx11-6 \
24
+ build-essential \
25
+ libsndfile-dev \
26
+ software-properties-common \
27
+ && rm -rf /var/lib/apt/lists/*
28
+
29
+ RUN add-apt-repository ppa:flexiondotorg/nvtop && \
30
+ apt-get upgrade -y && \
31
+ apt-get install -y --no-install-recommends nvtop
32
+
33
+ RUN curl -sL https://deb.nodesource.com/setup_21.x | bash - && \
34
+ apt-get install -y nodejs && \
35
+ npm install -g configurable-http-proxy
36
+
37
+ # Create a working directory
38
+ WORKDIR /app
39
+
40
+ # Create a non-root user and switch to it
41
+ RUN adduser --disabled-password --gecos '' --shell /bin/bash user \
42
+ && chown -R user:user /app
43
+ RUN echo "user ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/90-user
44
+ USER user
45
+
46
+ # All users can use /home/user as their home directory
47
+ ENV HOME=/home/user
48
+ RUN mkdir $HOME/.cache $HOME/.config \
49
+ && chmod -R 777 $HOME
50
+
51
+ # Set up the Conda environment
52
+ ENV CONDA_AUTO_UPDATE_CONDA=false \
53
+ PATH=$HOME/miniconda/bin:$PATH
54
+
55
+
56
+ RUN curl -sLo ~/miniconda.sh https://repo.anaconda.com/miniconda/Miniconda3-py313_25.5.1-1-Linux-x86_64.sh \
57
+ && chmod +x ~/miniconda.sh \
58
+ && ~/miniconda.sh -b -p ~/miniconda \
59
+ && rm ~/miniconda.sh \
60
+ && conda clean -ya
61
+
62
+ WORKDIR $HOME/app
63
+
64
+ #######################################
65
+ # Start root user section
66
+ #######################################
67
+
68
+ USER root
69
+
70
+ # User Debian packages
71
+ ## Security warning : Potential user code executed as root (build time)
72
+ RUN --mount=target=/root/packages.txt,source=packages.txt \
73
+ apt-get update && \
74
+ xargs -r -a /root/packages.txt apt-get install -y --no-install-recommends \
75
+ && rm -rf /var/lib/apt/lists/*
76
+
77
+ RUN --mount=target=/root/on_startup.sh,source=on_startup.sh,readwrite \
78
+ bash /root/on_startup.sh
79
+
80
+ RUN mkdir /data && chown user:user /data
81
+
82
+ #######################################
83
+ # End root user section
84
+ #######################################
85
+
86
+ USER user
87
+
88
+ # Python packages
89
+ RUN --mount=target=requirements.txt,source=requirements.txt \
90
+ pip install --no-cache-dir --upgrade -r requirements.txt
91
+
92
+ # Copy the current directory contents into the container at $HOME/app setting the owner to the user
93
+ COPY --chown=user . $HOME/app
94
+
95
+ RUN chmod +x start_server.sh
96
+
97
+ COPY --chown=user login.html /home/user/miniconda/lib/python3.13/site-packages/jupyter_server/templates/login.html
98
+
99
+ ENV PYTHONUNBUFFERED=1 \
100
+ GRADIO_ALLOW_FLAGGING=never \
101
+ GRADIO_NUM_PORTS=1 \
102
+ GRADIO_SERVER_NAME=0.0.0.0 \
103
+ GRADIO_THEME=huggingface \
104
+ SYSTEM=spaces \
105
+ SHELL=/bin/bash
106
+
107
+ CMD ["./start_server.sh"]
login.html ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {% extends "page.html" %}
2
+
3
+
4
+ {% block stylesheet %}
5
+ {% endblock %}
6
+
7
+ {% block site %}
8
+
9
+ <div id="jupyter-main-app" class="container">
10
+
11
+ <img src="https://huggingface.co/front/assets/huggingface_logo-noborder.svg" alt="Hugging Face Logo">
12
+ <h4>Welcome to JupyterLab</h4>
13
+
14
+ <h5>The default token is <span style="color:orange;">huggingface</span></h5>
15
+
16
+ {% if login_available %}
17
+ {# login_available means password-login is allowed. Show the form. #}
18
+ <div class="row">
19
+ <div class="navbar col-sm-8">
20
+ <div class="navbar-inner">
21
+ <div class="container">
22
+ <div class="center-nav">
23
+ <form action="{{base_url}}login?next={{next}}" method="post" class="navbar-form pull-left">
24
+ {{ xsrf_form_html() | safe }}
25
+ {% if token_available %}
26
+ <label for="password_input"><strong>{% trans %}Jupyter token <span title="This is the secret you set up when deploying your JupyterLab space">ⓘ</span> {% endtrans
27
+ %}</strong></label>
28
+ {% else %}
29
+ <label for="password_input"><strong>{% trans %}Jupyter password:{% endtrans %}</strong></label>
30
+ {% endif %}
31
+ <input type="password" name="password" id="password_input" class="form-control">
32
+ <button type="submit" class="btn btn-default" id="login_submit">{% trans %}Log in{% endtrans
33
+ %}</button>
34
+ </form>
35
+ </div>
36
+ </div>
37
+ </div>
38
+ </div>
39
+ </div>
40
+ {% else %}
41
+ <p>{% trans %}No login available, you shouldn't be seeing this page.{% endtrans %}</p>
42
+ {% endif %}
43
+
44
+ <h5>If you don't have the credentials for this Jupyter space, <a target="_blank" href="https://huggingface.co/spaces/SpacesExamples/jupyterlab?duplicate=true">create your own.</a></h5>
45
+ <br>
46
+
47
+ <p>This template was created by <a href="https://twitter.com/camenduru" target="_blank" >camenduru</a> and <a href="https://huggingface.co/nateraw" target="_blank" >nateraw</a>, with contributions of <a href="https://huggingface.co/osanseviero" target="_blank" >osanseviero</a> and <a href="https://huggingface.co/azzr" target="_blank" >azzr</a> </p>
48
+ {% if message %}
49
+ <div class="row">
50
+ {% for key in message %}
51
+ <div class="message {{key}}">
52
+ {{message[key]}}
53
+ </div>
54
+ {% endfor %}
55
+ </div>
56
+ {% endif %}
57
+ {% if token_available %}
58
+ {% block token_message %}
59
+
60
+ {% endblock token_message %}
61
+ {% endif %}
62
+ </div>
63
+
64
+ {% endblock %}
65
+
66
+
67
+ {% block script %}
68
+ {% endblock %}
on_startup.sh ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ # Write some commands here that will run on root user before startup.
3
+ # For example, to clone transformers and install it in dev mode:
4
+ # git clone https://github.com/huggingface/transformers.git
5
+ # cd transformers && pip install -e ".[dev]"
packages.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ tree
2
+ nano
3
+ xvfb
4
+ x11vnc
5
+ net-tools
requirements.txt ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ voila
2
+ httpx
3
+ torch
4
+ tornado
5
+ ipython
6
+ nbformat
7
+ nbclient
8
+ nbconvert
9
+ qtconsole
10
+ traitlets
11
+ ipykernel
12
+ langchain
13
+ faiss-cpu
14
+ streamlit
15
+ accelerate
16
+ ipywidgets
17
+ transformers
18
+
19
+ huggingface_hub
20
+ langchain_ollama
21
+ langchain_openai
22
+ langchain_openai
23
+ langchain_mistralai
24
+ sentence-transformers
25
+
26
+ jupyter
27
+ notebook
28
+ jupyterlab
29
+ jupyterhub
30
+ jupyter-ai[all]
31
+ jupyterlab-git
32
+ jupyterlab-lsp
33
+ python-lsp-server
34
+ jupyterlab-widgets
35
+ jupyter-server-proxy
36
+ jupyter_http_over_ws
37
+ #jupyterlab-proxy-gui
38
+ jupyter_contrib_nbextensions
39
+
40
+ #ipywidgets>=8.0.0
41
+ #tornado==6.2
42
+ #setuptools==65.5.0
requirements_org.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ jupyterlab==4.2.5
2
+ tornado==6.2
3
+ ipywidgets
start_server.sh ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ cd /data
4
+
5
+ JUPYTER_TOKEN="${JUPYTER_TOKEN:= huggingface}"
6
+
7
+ NOTEBOOK_DIR="/data"
8
+
9
+ # jupyter labextension disable "@jupyterlab/apputils-extension:announcements"
10
+ # jupyter server extension disable jupyterlab_proxy_gui
11
+
12
+ jupyter-lab \
13
+ --ip 0.0.0.0 \
14
+ --port 7860 \
15
+ --no-browser \
16
+ --allow-root \
17
+ --ServerApp.token="$JUPYTER_TOKEN" \
18
+ --IdentityProvider.token="$JUPYTER_TOKEN" \
19
+ --ServerApp.tornado_settings="{'headers': {'Content-Security-Policy': 'frame-ancestors *'}}" \
20
+ --ServerApp.cookie_options="{'SameSite': 'None', 'Secure': True}" \
21
+ --ServerApp.disable_check_xsrf=True \
22
+ --LabApp.news_url=None \
23
+ --LabApp.check_for_updates_class="jupyterlab.NeverCheckForUpdate" \
24
+ --notebook-dir=$NOTEBOOK_DIR