Akoss commited on
Commit
8b73798
1 Parent(s): a1a410d

Upload 6 files

Browse files
Files changed (6) hide show
  1. Dockerfile +102 -0
  2. login.html +69 -0
  3. on_startup.sh +5 -0
  4. packages.txt +1 -0
  5. requirements.txt +4 -0
  6. start_server.sh +19 -0
Dockerfile ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM nvidia/cuda:11.3.1-base-ubuntu20.04
2
+
3
+ ENV DEBIAN_FRONTEND=noninteractive \
4
+ TZ=Europe/Paris
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
+ wget \
11
+ curl \
12
+ ca-certificates \
13
+ sudo \
14
+ git \
15
+ git-lfs \
16
+ zip \
17
+ unzip \
18
+ htop \
19
+ bzip2 \
20
+ libx11-6 \
21
+ build-essential \
22
+ libsndfile-dev \
23
+ software-properties-common \
24
+ && rm -rf /var/lib/apt/lists/*
25
+
26
+ RUN add-apt-repository ppa:flexiondotorg/nvtop && \
27
+ apt-get upgrade -y && \
28
+ apt-get install -y --no-install-recommends nvtop
29
+
30
+ RUN curl -sL https://deb.nodesource.com/setup_14.x | bash - && \
31
+ apt-get install -y nodejs && \
32
+ npm install -g configurable-http-proxy
33
+
34
+ # Create a working directory
35
+ WORKDIR /app
36
+
37
+ # Create a non-root user and switch to it
38
+ RUN adduser --disabled-password --gecos '' --shell /bin/bash user \
39
+ && chown -R user:user /app
40
+ RUN echo "user ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/90-user
41
+ USER user
42
+
43
+ # All users can use /home/user as their home directory
44
+ ENV HOME=/home/user
45
+ RUN mkdir $HOME/.cache $HOME/.config \
46
+ && chmod -R 777 $HOME
47
+
48
+ # Set up the Conda environment
49
+ ENV CONDA_AUTO_UPDATE_CONDA=false \
50
+ PATH=$HOME/miniconda/bin:$PATH
51
+ RUN curl -sLo ~/miniconda.sh https://repo.continuum.io/miniconda/Miniconda3-py39_4.10.3-Linux-x86_64.sh \
52
+ && chmod +x ~/miniconda.sh \
53
+ && ~/miniconda.sh -b -p ~/miniconda \
54
+ && rm ~/miniconda.sh \
55
+ && conda clean -ya
56
+
57
+ WORKDIR $HOME/app
58
+
59
+ #######################################
60
+ # Start root user section
61
+ #######################################
62
+
63
+ USER root
64
+
65
+ # User Debian packages
66
+ ## Security warning : Potential user code executed as root (build time)
67
+ RUN --mount=target=/root/packages.txt,source=packages.txt \
68
+ apt-get update && \
69
+ xargs -r -a /root/packages.txt apt-get install -y --no-install-recommends \
70
+ && rm -rf /var/lib/apt/lists/*
71
+
72
+ RUN --mount=target=/root/on_startup.sh,source=on_startup.sh,readwrite \
73
+ bash /root/on_startup.sh
74
+
75
+ RUN chown user:user $HOME/app
76
+
77
+ #######################################
78
+ # End root user section
79
+ #######################################
80
+
81
+ USER user
82
+
83
+ # Python packages
84
+ RUN --mount=target=requirements.txt,source=requirements.txt \
85
+ pip install --no-cache-dir --upgrade -r requirements.txt
86
+
87
+ # Copy the current directory contents into the container at $HOME/app setting the owner to the user
88
+ COPY --chown=user . $HOME/app
89
+
90
+ RUN chmod +x start_server.sh
91
+
92
+ COPY --chown=user login.html /home/user/miniconda/lib/python3.9/site-packages/jupyter_server/templates/login.html
93
+
94
+ ENV PYTHONUNBUFFERED=1 \
95
+ GRADIO_ALLOW_FLAGGING=never \
96
+ GRADIO_NUM_PORTS=1 \
97
+ GRADIO_SERVER_NAME=0.0.0.0 \
98
+ GRADIO_THEME=huggingface \
99
+ SYSTEM=spaces \
100
+ SHELL=/bin/bash
101
+
102
+ CMD ["./start_server.sh"]
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 can duplicate this Space to run it private.</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 ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ jupyterlab==3.6.1
2
+ jupyter-server==2.3.0
3
+ tornado==6.2
4
+ ipywidgets
start_server.sh ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ JUPYTER_TOKEN="${JUPYTER_TOKEN:=huggingface}"
3
+
4
+ echo "Starting Jupyter Lab with token $JUPYTER_TOKEN"
5
+
6
+ NOTEBOOK_DIR="/home/user/app"
7
+
8
+ jupyter-lab \
9
+ --ip 0.0.0.0 \
10
+ --port 7860 \
11
+ --no-browser \
12
+ --allow-root \
13
+ --ServerApp.token="$JUPYTER_TOKEN" \
14
+ --ServerApp.tornado_settings="{'headers': {'Content-Security-Policy': 'frame-ancestors *'}}" \
15
+ --ServerApp.cookie_options="{'SameSite': 'None', 'Secure': True}" \
16
+ --ServerApp.disable_check_xsrf=True \
17
+ --LabApp.news_url=None \
18
+ --LabApp.check_for_updates_class="jupyterlab.NeverCheckForUpdate" \
19
+ --notebook-dir=$NOTEBOOK_DIR