derek-thomas HF staff commited on
Commit
9999e5f
1 Parent(s): 6d3aa6a

Adding jupyterlab

Browse files
Files changed (2) hide show
  1. Dockerfile +88 -28
  2. requirements.txt +0 -1
Dockerfile CHANGED
@@ -1,44 +1,104 @@
1
  # Start from the TGI base image
2
  FROM ghcr.io/huggingface/text-generation-inference:2.0 as base
3
 
4
- # Install git
5
- RUN apt-get update && apt-get install -y git
 
 
6
 
7
- COPY ./requirements.txt /code/requirements.txt
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
 
9
- RUN pip install -r /code/requirements.txt
 
 
10
 
11
- # Create a non-root user with UID 1000
12
- RUN useradd -m -u 1000 -s /bin/bash user
 
13
 
14
- # Create the /data directory and set its ownership
15
- RUN mkdir /data && chown user:user /data
16
 
17
- # Switch to the non-root user
 
 
 
18
  USER user
19
 
20
- # Set working directory
21
- WORKDIR /home/user
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
 
23
- # Add local python bin directory to PATH
24
- ENV PATH="/home/user/.local/bin:${PATH}"
25
 
26
- # Override the ENTRYPOINT
27
- ENTRYPOINT []
 
 
 
 
 
 
 
 
 
28
 
29
- # Set home to the user's home directory
30
- ENV HOME=/home/user \
31
- PATH=/home/user/.local/bin:$PATH \
32
- PYTHONPATH=$HOME/app \
33
- PYTHONUNBUFFERED=1 \
34
- GRADIO_ALLOW_FLAGGING=never \
35
- GRADIO_NUM_PORTS=1 \
36
- GRADIO_SERVER_NAME=0.0.0.0 \
37
- GRADIO_THEME=huggingface \
38
- SYSTEM=spaces
39
 
40
  # Copy the current directory contents into the container at $HOME/app setting the owner to the user
41
- COPY --chown=user . $HOME/
 
 
 
 
 
 
 
 
 
 
 
 
42
 
43
- # Set the CMD to run your script
44
- CMD python /home/user/app.py
 
1
  # Start from the TGI base image
2
  FROM ghcr.io/huggingface/text-generation-inference:2.0 as base
3
 
4
+ #COPY ./requirements.txt /code/requirements.txt
5
+ #
6
+ #RUN pip install -r /code/requirements.txt
7
+ #RUN pip install jupyterlab jupyterlab-vim==0.15.1 jupyterlab-vimrc
8
 
9
+ # Remove any third-party apt sources to avoid issues with expiring keys.
10
+ # Install some basic utilities
11
+ RUN rm -f /etc/apt/sources.list.d/*.list && \
12
+ apt-get update && apt-get install -y --no-install-recommends \
13
+ curl \
14
+ ca-certificates \
15
+ sudo \
16
+ git \
17
+ git-lfs \
18
+ zip \
19
+ unzip \
20
+ htop \
21
+ bzip2 \
22
+ libx11-6 \
23
+ build-essential \
24
+ libsndfile-dev \
25
+ software-properties-common \
26
+ && rm -rf /var/lib/apt/lists/*
27
 
28
+ RUN add-apt-repository ppa:flexiondotorg/nvtop && \
29
+ apt-get upgrade -y && \
30
+ apt-get install -y --no-install-recommends nvtop
31
 
32
+ RUN curl -sL https://deb.nodesource.com/setup_14.x | bash - && \
33
+ apt-get install -y nodejs && \
34
+ npm install -g configurable-http-proxy
35
 
36
+ # Create a working directory
37
+ WORKDIR /app
38
 
39
+ # Create a non-root user and switch to it
40
+ RUN adduser --disabled-password --gecos '' --shell /bin/bash user \
41
+ && chown -R user:user /app
42
+ RUN echo "user ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/90-user
43
  USER user
44
 
45
+ # All users can use /home/user as their home directory
46
+ ENV HOME=/home/user
47
+ RUN mkdir $HOME/.cache $HOME/.config \
48
+ && chmod -R 777 $HOME
49
+
50
+ # Set up the Conda environment
51
+ ENV CONDA_AUTO_UPDATE_CONDA=false \
52
+ PATH=$HOME/miniconda/bin:$PATH
53
+ RUN curl -sLo ~/miniconda.sh https://repo.continuum.io/miniconda/Miniconda3-py39_4.10.3-Linux-x86_64.sh \
54
+ && chmod +x ~/miniconda.sh \
55
+ && ~/miniconda.sh -b -p ~/miniconda \
56
+ && rm ~/miniconda.sh \
57
+ && conda clean -ya
58
+
59
+ WORKDIR $HOME/app
60
+
61
+ #######################################
62
+ # Start root user section
63
+ #######################################
64
 
65
+ USER root
 
66
 
67
+ # User Debian packages
68
+ ## Security warning : Potential user code executed as root (build time)
69
+ RUN --mount=target=/root/packages.txt,source=packages.txt \
70
+ apt-get update && \
71
+ xargs -r -a /root/packages.txt apt-get install -y --no-install-recommends \
72
+ && rm -rf /var/lib/apt/lists/*
73
+
74
+ RUN --mount=target=/root/on_startup.sh,source=on_startup.sh,readwrite \
75
+ bash /root/on_startup.sh
76
+
77
+ RUN mkdir /data && chown user:user /data
78
 
79
+ #######################################
80
+ # End root user section
81
+ #######################################
82
+
83
+ USER user
84
+
85
+ # Python packages
86
+ RUN --mount=target=requirements.txt,source=requirements.txt \
87
+ pip install --no-cache-dir --upgrade -r requirements.txt
 
88
 
89
  # Copy the current directory contents into the container at $HOME/app setting the owner to the user
90
+ COPY --chown=user ./jupyterlab $HOME/app
91
+
92
+ RUN chmod +x start_server.sh
93
+
94
+ COPY --chown=user login.html /home/user/miniconda/lib/python3.9/site-packages/jupyter_server/templates/login.html
95
+
96
+ ENV PYTHONUNBUFFERED=1 \
97
+ GRADIO_ALLOW_FLAGGING=never \
98
+ GRADIO_NUM_PORTS=1 \
99
+ GRADIO_SERVER_NAME=0.0.0.0 \
100
+ GRADIO_THEME=huggingface \
101
+ SYSTEM=spaces \
102
+ SHELL=/bin/bash
103
 
104
+ CMD ["./start_server.sh"]
 
requirements.txt DELETED
@@ -1 +0,0 @@
1
- gradio==4.26.0