atonyxu commited on
Commit
46e7598
·
verified ·
1 Parent(s): 73ea142

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +100 -10
Dockerfile CHANGED
@@ -1,15 +1,105 @@
1
- # 使用Ollama的基础镜像
2
- FROM ollama/ollama:latest
3
 
4
- # 设置工作目录
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  WORKDIR /app
6
 
7
- # 复制启动脚本(如果有)
8
- COPY start_server.sh /app/start_server.sh
9
- RUN chmod +x /app/start_server.sh
 
 
10
 
11
- # 暴露Ollama的默认端口
12
- EXPOSE 11434
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
 
14
- # 执行拉取模型和启动Ollama服务的脚本
15
- CMD ["/app/start_server.sh"]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM nvidia/cuda:12.5.1-cudnn-devel-ubuntu20.04
 
2
 
3
+ ENV DEBIAN_FRONTEND=noninteractive \
4
+ TZ=Asia/Shanghai
5
+
6
+ RUN rm -f /etc/apt/sources.list.d/*.list && \
7
+ apt-get update && apt-get install -y --no-install-recommends \
8
+ curl \
9
+ ca-certificates \
10
+ sudo \
11
+ git \
12
+ wget \
13
+ aria2 \
14
+ axel \
15
+ procps \
16
+ git-lfs \
17
+ zip \
18
+ unzip \
19
+ htop \
20
+ vim \
21
+ nano \
22
+ bzip2 \
23
+ libx11-6 \
24
+ build-essential \
25
+ libsndfile-dev \
26
+ software-properties-common \
27
+ && rm -rf /var/lib/apt/lists/*
28
+
29
+ RUN add-apt-repository ppa:flexiondotorg/nvtop && \
30
+ apt-get upgrade -y && \
31
+ apt-get install -y --no-install-recommends nvtop
32
+
33
+ RUN curl -sL https://deb.nodesource.com/setup_21.x | bash - && \
34
+ apt-get install -y nodejs && \
35
+ npm install -g configurable-http-proxy
36
+
37
+ # Create a working directory
38
  WORKDIR /app
39
 
40
+ # Create a non-root user and switch to it
41
+ RUN adduser --disabled-password --gecos '' --shell /bin/bash user \
42
+ && chown -R user:user /app
43
+ RUN echo "user ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/90-user
44
+ USER user
45
 
46
+ # All users can use /home/user as their home directory
47
+ ENV HOME=/home/user
48
+ RUN mkdir $HOME/.cache $HOME/.config \
49
+ && chmod -R 777 $HOME
50
+
51
+ # Set up the Conda environment
52
+ ENV CONDA_AUTO_UPDATE_CONDA=false \
53
+ PATH=$HOME/miniconda/bin:$PATH
54
+ RUN curl -sLo ~/miniconda.sh https://repo.continuum.io/miniconda/Miniconda3-py39_4.10.3-Linux-x86_64.sh \
55
+ && chmod +x ~/miniconda.sh \
56
+ && ~/miniconda.sh -b -p ~/miniconda \
57
+ && rm ~/miniconda.sh \
58
+ && conda clean -ya
59
+
60
+ WORKDIR $HOME/app
61
+
62
+ #######################################
63
+ # Start root user section
64
+ #######################################
65
+
66
+ USER root
67
 
68
+ # User Debian packages
69
+ ## Security warning : Potential user code executed as root (build time)
70
+ RUN --mount=target=/root/packages.txt,source=packages.txt \
71
+ apt-get update && \
72
+ xargs -r -a /root/packages.txt apt-get install -y --no-install-recommends \
73
+ && rm -rf /var/lib/apt/lists/*
74
+
75
+ RUN --mount=target=/root/on_startup.sh,source=on_startup.sh,readwrite \
76
+ bash /root/on_startup.sh
77
+
78
+ RUN mkdir /data && chown user:user /data
79
+ RUN curl -fsSL https://ollama.com/install.sh | sh
80
+ #######################################
81
+ # End root user section
82
+ #######################################
83
+
84
+ USER user
85
+
86
+ # Python packages
87
+ RUN pip install glances
88
+
89
+ # Copy the current directory contents into the container at $HOME/app setting the owner to the user
90
+ COPY --chown=user . $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
+ WORKDIR /data
104
+ EXPOSE 11434
105
+ CMD ["/home/user/app/start_server.sh"]