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V CPU_CORES=8
|
| 6 |
+
ENV MEMORY=32Gi
|
| 7 |
+
|
| 8 |
+
# 1. 安装 NGINX 编译所需的依赖
|
| 9 |
+
RUN apk update && \
|
| 10 |
+
apk add --no-cache \
|
| 11 |
+
wget \
|
| 12 |
+
gcc \
|
| 13 |
+
g++ \
|
| 14 |
+
make \
|
| 15 |
+
pcre-dev \
|
| 16 |
+
openssl-dev \
|
| 17 |
+
zlib-dev \
|
| 18 |
+
linux-headers
|
| 19 |
+
|
| 20 |
+
# 2. 下载并解压 NGINX 源码
|
| 21 |
+
RUN mkdir -p /data/tools && \
|
| 22 |
+
wget -P /data/tools/ http://nginx.org/download/nginx-1.24.0.tar.gz && \
|
| 23 |
+
tar -xf /data/tools/nginx-1.24.0.tar.gz -C /data/tools/
|
| 24 |
+
|
| 25 |
+
# 3. 编译和安装 NGINX
|
| 26 |
+
# 修复说明: 添加了 --with-cc-opt="-Wno-error" 以解决 GCC 编译报错
|
| 27 |
+
RUN cd /data/tools/nginx-1.24.0 && \
|
| 28 |
+
./configure --prefix=/data/nginx1.24 \
|
| 29 |
+
--with-http_ssl_module \
|
| 30 |
+
--with-http_v2_module \
|
| 31 |
+
--with-http_stub_status_module \
|
| 32 |
+
--with-threads \
|
| 33 |
+
--with-file-aio \
|
| 34 |
+
--with-cc-opt="-Wno-error" \
|
| 35 |
+
--error-log-path=/data/nginx1.24/logs/error.log \
|
| 36 |
+
--http-log-path=/data/nginx1.24/logs/access.log \
|
| 37 |
+
--pid-path=/data/nginx1.24/nginx.pid \
|
| 38 |
+
--http-client-body-temp-path=/data/nginx1.24/client_body_temp \
|
| 39 |
+
--http-proxy-temp-path=/data/nginx1.24/proxy_temp \
|
| 40 |
+
--http-fastcgi-temp-path=/data/nginx1.24/fastcgi_temp \
|
| 41 |
+
--http-uwsgi-temp-path=/data/nginx1.24/uwsgi_temp \
|
| 42 |
+
--http-scgi-temp-path=/data/nginx1.24/scgi_temp && \
|
| 43 |
+
make && \
|
| 44 |
+
make install
|
| 45 |
+
|
| 46 |
+
# 4. 设置权限
|
| 47 |
+
RUN chmod -R 777 /data/nginx1.24 && \
|
| 48 |
+
chown -R nobody:nobody /data/nginx1.24
|
| 49 |
+
|
| 50 |
+
# 5. 创建基本的 nginx.conf 配置文件
|
| 51 |
+
# 修复说明: 修正了最后几行的文件名 (原为 conf/nginx) 并补全了缺少的闭合括号 "}"
|
| 52 |
+
RUN echo "user nobody nobody;" > /data/nginx1.24/conf/nginx.conf && \
|
| 53 |
+
echo "worker_processes auto;" >> /data/nginx1.24/conf/nginx.conf && \
|
| 54 |
+
echo "error_log /data/nginx1.24/logs/error.log;" >> /data/nginx1.24/conf/nginx.conf && \
|
| 55 |
+
echo "pid /data/nginx1.24/nginx.pid;" >> /data/nginx1.24/conf/nginx.conf && \
|
| 56 |
+
echo "" >> /data/nginx1.24/conf/nginx.conf && \
|
| 57 |
+
echo "events {" >> /data/nginx1.24/conf/nginx.conf && \
|
| 58 |
+
echo " worker_connections 1024;" >> /data/nginx1.24/conf/nginx.conf && \
|
| 59 |
+
echo "}" >> /data/nginx1.24/conf/nginx.conf && \
|
| 60 |
+
echo "" >> /data/nginx1.24/conf/nginx.conf && \
|
| 61 |
+
echo "http {" >> /data/nginx1.24/conf/nginx.conf && \
|
| 62 |
+
echo " include mime.types;" >> /data/nginx1.24/conf/nginx.conf && \
|
| 63 |
+
echo " default_type application/octet-stream;" >> /data/nginx1.24/conf/nginx.conf && \
|
| 64 |
+
echo " server {" >> /data/nginx1.24/conf/nginx.conf && \
|
| 65 |
+
echo " listen 80;" >> /data/nginx1.24/conf/nginx.conf && \
|
| 66 |
+
echo " }" >> /data/nginx1.24/conf/nginx.conf && \
|
| 67 |
+
echo "}" >> /data/nginx1.24/conf/nginx.conf
|
| 68 |
+
|
| 69 |
+
# 6. 安装 Python 环境及其他工具依赖
|
| 70 |
+
RUN apk update && \
|
| 71 |
+
apk add --no-cache \
|
| 72 |
+
ca-certificates \
|
| 73 |
+
curl \
|
| 74 |
+
wget \
|
| 75 |
+
bzip2 \
|
| 76 |
+
p7zip \
|
| 77 |
+
pigz \
|
| 78 |
+
pv \
|
| 79 |
+
git \
|
| 80 |
+
git-lfs \
|
| 81 |
+
sudo \
|
| 82 |
+
python3 \
|
| 83 |
+
python3-dev \
|
| 84 |
+
py3-pip \
|
| 85 |
+
build-base \
|
| 86 |
+
linux-headers \
|
| 87 |
+
gcc \
|
| 88 |
+
musl-dev \
|
| 89 |
+
libffi-dev \
|
| 90 |
+
openssl-dev \
|
| 91 |
+
nodejs \
|
| 92 |
+
npm \
|
| 93 |
+
bash \
|
| 94 |
+
py3-requests \
|
| 95 |
+
py3-flask \
|
| 96 |
+
py3-pexpect \
|
| 97 |
+
py3-psutil
|
| 98 |
+
|
| 99 |
+
# 7. 创建工作目录和权限
|
| 100 |
+
RUN mkdir -p /tmp/app /tmp/app/frp /.kaggle /data /root/.kaggle && \
|
| 101 |
+
chmod -R 777 /tmp/app /tmp/app/frp /.kaggle /data /root/.kaggle
|
| 102 |
+
|
| 103 |
+
# 8. 设置工作目录
|
| 104 |
+
WORKDIR /data
|
| 105 |
+
|
| 106 |
+
# 9. 创建虚拟环境并安装 Python 包
|
| 107 |
+
RUN python3 -m venv /opt/venv && \
|
| 108 |
+
. /opt/venv/bin/activate && \
|
| 109 |
+
pip install --upgrade pip && \
|
| 110 |
+
pip install --no-cache-dir \
|
| 111 |
+
jupyterlab \
|
| 112 |
+
notebook \
|
| 113 |
+
pexpect \
|
| 114 |
+
psutil \
|
| 115 |
+
requests \
|
| 116 |
+
pytz \
|
| 117 |
+
flask \
|
| 118 |
+
kaggle \
|
| 119 |
+
PyYAML \
|
| 120 |
+
huggingface_hub \
|
| 121 |
+
ipykernel
|
| 122 |
+
|
| 123 |
+
# 10. 安装 configurable-http-proxy
|
| 124 |
+
RUN npm install -g configurable-http-proxy
|
| 125 |
+
|
| 126 |
+
# 11. 配置 sudo
|
| 127 |
+
RUN echo "root ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers && \
|
| 128 |
+
chmod 0440 /etc/sudoers
|
| 129 |
+
|
| 130 |
+
# 12. 设置环境变量
|
| 131 |
+
ENV JUPYTER_RUNTIME_DIR=/tmp/app/runtime
|
| 132 |
+
ENV JUPYTER_DATA_DIR=/tmp/app/data
|
| 133 |
+
ENV HOME=/tmp/app
|
| 134 |
+
ENV PATH="/opt/venv/bin:$PATH"
|
| 135 |
+
ENV JUPYTER_TOKEN=${JUPYTER_TOKEN}
|
| 136 |
+
|
| 137 |
+
# 13. 创建运行时目录
|
| 138 |
+
RUN mkdir -p /tmp/app/runtime && \
|
| 139 |
+
chmod 777 /tmp/app/runtime
|
| 140 |
+
|
| 141 |
+
# 14. 暴露端口及启动脚本
|
| 142 |
+
EXPOSE 7860
|
| 143 |
+
|
| 144 |
+
RUN wget -O '/data/start_server.sh' 'https://huggingface.co/datasets/Qilan2/ff/raw/main/nv1/start_server.sh' && \
|
| 145 |
+
wget -O '/data/app.py' 'https://huggingface.co/datasets/Qilan2/ff/raw/main/nv1/app.py' && \
|
| 146 |
+
chmod +x /data/start_server.sh
|
| 147 |
+
|
| 148 |
+
CMD ["/data/start_server.sh"]
|