Zhofang commited on
Commit
045198b
·
verified ·
1 Parent(s): c405bce

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +102 -7
Dockerfile CHANGED
@@ -1,10 +1,91 @@
1
- FROM python:3.9
 
 
2
 
3
- WORKDIR /code
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
 
5
- COPY ./requirements.txt /code/requirements.txt
 
 
6
 
7
- RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  RUN pip uninstall numpy -y
9
  RUN pip install jq
10
  RUN apt update && apt upgrade -y
@@ -13,8 +94,22 @@ RUN apt install bc
13
  RUN apt install nodejs -y
14
 
15
  RUN pip install numpy==1.26.4
16
- COPY . .
 
 
 
 
 
 
 
 
17
 
18
- EXPOSE 7860
 
 
 
 
 
 
19
 
20
- CMD ["shiny", "run", "app.py", "--host", "0.0.0.0", "--port", "7860"]
 
1
+ FROM nvidia/cuda:11.3.1-base-ubuntu20.04
2
+ ENV DEBIAN_FRONTEND=noninteractive \
3
+ TZ=Europe/Paris
4
 
5
+ # Remove any third-party apt sources to avoid issues with expiring keys.
6
+ # Install some basic utilities
7
+ RUN rm -f /etc/apt/sources.list.d/*.list && \
8
+ apt-get update && apt-get install -y --no-install-recommends \
9
+ curl \
10
+ ca-certificates \
11
+ sudo \
12
+ git \
13
+ wget \
14
+ procps \
15
+ git-lfs \
16
+ zip \
17
+ unzip \
18
+ sysbench \
19
+ htop \
20
+ nload \
21
+ vim \
22
+ nmap \
23
+ neofetch \
24
+ nano \
25
+ bzip2 \
26
+ libx11-6 \
27
+ python3-pip \
28
+ build-essential \
29
+ libsndfile-dev \
30
+ software-properties-common \
31
+ && rm -rf /var/lib/apt/lists/*
32
 
33
+ RUN add-apt-repository ppa:flexiondotorg/nvtop && \
34
+ apt-get upgrade -y && \
35
+ apt-get install -y --no-install-recommends nvtop
36
 
37
+ RUN curl -sL https://deb.nodesource.com/setup_14.x | bash - && \
38
+ apt-get install -y nodejs && \
39
+ npm install -g configurable-http-proxy
40
+
41
+ # Create a working directory
42
+ WORKDIR /app
43
+
44
+ # Create a non-root user and switch to it
45
+ RUN adduser --disabled-password --gecos '' --shell /bin/bash user \
46
+ && chown -R user:user /app
47
+ RUN echo "user ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/90-user
48
+ USER user
49
+
50
+ # All users can use /home/user as their home directory
51
+ ENV HOME=/home/user
52
+ RUN mkdir $HOME/.cache $HOME/.config \
53
+ && chmod -R 777 $HOME
54
+
55
+ # Set up the Conda environment
56
+ ENV CONDA_AUTO_UPDATE_CONDA=false \
57
+ PATH=$HOME/miniconda/bin:$PATH
58
+ RUN curl -sLo ~/miniconda.sh https://repo.continuum.io/miniconda/Miniconda3-py39_4.10.3-Linux-x86_64.sh \
59
+ && chmod +x ~/miniconda.sh \
60
+ && ~/miniconda.sh -b -p ~/miniconda \
61
+ && rm ~/miniconda.sh \
62
+ && conda clean -ya
63
+
64
+ WORKDIR $HOME/app
65
+
66
+ #######################################
67
+ # Start root user section
68
+ #######################################
69
+
70
+ USER root
71
+
72
+ # User Debian packages
73
+ ## Security warning : Potential user code executed as root (build time)
74
+ RUN --mount=target=/root/packages.txt,source=packages.txt \
75
+ apt-get update && \
76
+ xargs -r -a /root/packages.txt apt-get install -y --no-install-recommends \
77
+ && rm -rf /var/lib/apt/lists/*
78
+
79
+ RUN --mount=target=/root/on_startup.sh,source=on_startup.sh,readwrite \
80
+ bash /root/on_startup.sh
81
+
82
+ RUN mkdir /data && chown user:user /data
83
+ RUN pip install bottle
84
+ RUN pip install glances
85
+ RUN pip install fastapi
86
+ RUN pip install uvicorn
87
+ RUN pip install Jinja2==3.1.2
88
+ RUN pip install --no-cache-dir --upgrade -r requirements.txt
89
  RUN pip uninstall numpy -y
90
  RUN pip install jq
91
  RUN apt update && apt upgrade -y
 
94
  RUN apt install nodejs -y
95
 
96
  RUN pip install numpy==1.26.4
97
+ #######################################
98
+ # End root user section
99
+ #######################################
100
+
101
+ USER user
102
+
103
+ # Python packages
104
+ # Copy the current directory contents into the container at $HOME/app setting the owner to the user
105
+ COPY --chown=user . $HOME/app
106
 
107
+ ENV PYTHONUNBUFFERED=1 \
108
+ GRADIO_ALLOW_FLAGGING=never \
109
+ GRADIO_NUM_PORTS=1 \
110
+ GRADIO_SERVER_NAME=0.0.0.0 \
111
+ GRADIO_THEME=huggingface \
112
+ SYSTEM=spaces \
113
+ SHELL=/bin/bash
114
 
115
+ CMD ["glances", "-w", "-p", "7860"]