atonyxu commited on
Commit
d2b7789
·
verified ·
1 Parent(s): e8117ef

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +108 -9
Dockerfile CHANGED
@@ -1,12 +1,111 @@
1
- # 使用官方基础镜像
2
- FROM mltooling/ml-workspace:0.13.2
3
 
4
- # 设置环境变量
5
- ENV AUTHENTICATE_VIA_JUPYTER="mytoken"
6
 
7
- # 暴露端口(这只是一个声明,实际端口映射是在运行时由 -p 参数控制)
8
- EXPOSE 8080
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
 
10
- # 如果有特定的命令或脚本需要在容器启动时运行,可以在这里设置
11
- # CMD ENTRYPOINT 可以用来设置默认命令
12
- # 注意,这不会自动处理卷挂载、容器名、共享内存大小或重启策略
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM nvidia/cuda:12.5.1-cudnn-devel-ubuntu20.04
 
2
 
3
+ ENV DEBIAN_FRONTEND=noninteractive \
4
+ TZ=Asia/Shanghai
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
+ aria2 \
16
+ axel \
17
+ procps \
18
+ git-lfs \
19
+ zip \
20
+ unzip \
21
+ htop \
22
+ vim \
23
+ nano \
24
+ bzip2 \
25
+ libx11-6 \
26
+ build-essential \
27
+ libsndfile-dev \
28
+ software-properties-common \
29
+ && rm -rf /var/lib/apt/lists/*
30
 
31
+ RUN add-apt-repository ppa:flexiondotorg/nvtop && \
32
+ apt-get upgrade -y && \
33
+ apt-get install -y --no-install-recommends nvtop
34
+
35
+ RUN curl -sL https://deb.nodesource.com/setup_21.x | bash - && \
36
+ apt-get install -y nodejs && \
37
+ npm install -g configurable-http-proxy
38
+
39
+ # Create a working directory
40
+ WORKDIR /app
41
+
42
+ # Create a non-root user and switch to it
43
+ RUN adduser --disabled-password --gecos '' --shell /bin/bash user \
44
+ && chown -R user:user /app
45
+ RUN echo "user ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/90-user
46
+ USER user
47
+
48
+ # All users can use /home/user as their home directory
49
+ ENV HOME=/home/user
50
+ RUN mkdir $HOME/.cache $HOME/.config \
51
+ && chmod -R 777 $HOME
52
+
53
+ # Set up the Conda environment
54
+ ENV CONDA_AUTO_UPDATE_CONDA=false \
55
+ PATH=$HOME/miniconda/bin:$PATH
56
+ RUN curl -sLo ~/miniconda.sh https://repo.continuum.io/miniconda/Miniconda3-py39_4.10.3-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
+ pip install glances modelscope huggingface_hub jupyterlab-language-pack-zh-CN
92
+
93
+ # Copy the current directory contents into the container at $HOME/app setting the owner to the user
94
+ COPY --chown=user . $HOME/app
95
+
96
+ RUN chmod +x start_server.sh
97
+
98
+ COPY --chown=user login.html /home/user/miniconda/lib/python3.9/site-packages/jupyter_server/templates/login.html
99
+
100
+ ENV PYTHONUNBUFFERED=1 \
101
+ GRADIO_ALLOW_FLAGGING=never \
102
+ GRADIO_NUM_PORTS=1 \
103
+ GRADIO_SERVER_NAME=0.0.0.0 \
104
+ GRADIO_THEME=huggingface \
105
+ SYSTEM=spaces \
106
+ SHELL=/bin/bash
107
+
108
+ RUN curl -fsSL https://code-server.dev/install.sh | sh
109
+ RUN sudo systemctl enable --now code-server@$USER
110
+ RUN echo "password: ${JUPYTER_TOKEN:=huggingface}"
111
+ WORKDIR /data