File size: 1,874 Bytes
9fa6c95
 
cb8bd56
 
 
 
 
 
 
 
 
9fa6c95
cb8bd56
 
84ba54a
 
6804ce1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
cb8bd56
5c78a8d
cb8bd56
 
 
 
d52b6ec
ce699bf
cb8bd56
 
 
b32b02f
cb8bd56
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
FROM opcl26/opcl:latest

# 复制 Cloudflared 配置
# 2. 安装 Cloudflare Tunnel
RUN curl -L --output /usr/local/bin/cloudflared https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64 && \
    chmod +x /usr/local/bin/cloudflared
#COPY config.yml /etc/cloudflared/config.yml

# 启动脚本
#COPY start.sh /start.sh
#RUN chmod +x /start.sh
#RUN npm install -g openclaw@latest
# 暴露端口(容器内)

RUN curl -fsSL https://ollama.com/install.sh | sh

# 复制 Nginx 配置
#COPY nginx.conf /etc/nginx/nginx.conf
# 5. 覆盖默认配置,监听 7860 端口
# 注意:非 root 用户无法监听 1024 以下的端口(如 80),但可以监听 7860
RUN echo 'server { \
    listen 7860; \
    server_name localhost; \
    location / { \
        root /usr/share/nginx/html; \
        index index.html index.htm; \
        try_files $uri $uri/ /index.html; \
        default_type text/plain; \
        return 200 "Hello World"; \
    } \
}' > /etc/nginx/conf.d/default.conf

RUN useradd -m -u 1001 user && \
    echo "user:hf123" | chpasswd

# 4. 目录授权 (关键步骤)
RUN mkdir -p /var/run/sshd /app/.cloudflared && \
    mkdir -p /var/cache/nginx /var/log/nginx /var/lib/nginx && \
    chown -R user:user /usr/share/nginx/html /var/cache/nginx /var/log/nginx /var/lib/nginx /etc/nginx /var/run/sshd /etc/ssh /var/run /app && \
    touch /var/run/nginx.pid && \
    chown user:user /var/run/nginx.pid

RUN chmod 644 /etc/shadow   

# 暴露 7860 (Web) 和 2222 (SSH)
EXPOSE 7860 2222
# 3. 切换到非 root 用户
USER user
WORKDIR /app

# 复制并设置 entrypoint 脚本
COPY --chown=user entrypoint.sh /app/entrypoint.sh
RUN chmod +x /app/entrypoint.sh
#CMD sh -c "#/usr/sbin/sshd && \ nginx -g 'daemon off;'"
#CMD /usr/sbin/sshd && nginx -g "daemon off;"
#CMD ["nginx", "-g", "daemon off;"]
CMD ["/app/entrypoint.sh"]