darkfire514 commited on
Commit
a272828
·
verified ·
1 Parent(s): 51d811d

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +31 -54
Dockerfile CHANGED
@@ -1,76 +1,53 @@
1
- # Use a lightweight Debian base for a simplified Linux environment
2
  FROM debian:bookworm-slim
3
 
4
- # Set environment variables to avoid interactive prompts during installation
5
  ENV DEBIAN_FRONTEND=noninteractive
6
  ENV HOME=/home/user
7
- ENV PATH=$HOME/.local/bin:$PATH
8
 
9
- # Install essential system packages and build tools
10
  RUN apt-get update && apt-get install -y \
11
- curl \
12
- wget \
13
- git \
14
- sudo \
15
- vim \
16
- nano \
17
- unzip \
18
- procps \
19
- net-tools \
20
- netcat-openbsd \
21
- build-essential \
22
- cmake \
23
- pkg-config \
24
- python3 \
25
- nginx \
26
- xz-utils \
27
- bzip2 \
28
- ca-certificates \
29
  && apt-get clean && rm -rf /var/lib/apt/lists/*
30
 
31
- # Install ttyd (Web Terminal)
 
 
 
 
 
 
 
 
32
  RUN wget https://github.com/tsl0922/ttyd/releases/download/1.7.7/ttyd.x86_64 -O /usr/bin/ttyd \
33
  && chmod +x /usr/bin/ttyd
34
 
35
- # Install oauth2-proxy
36
- # Download v7.6.0 release
37
  RUN wget https://github.com/oauth2-proxy/oauth2-proxy/releases/download/v7.6.0/oauth2-proxy-v7.6.0.linux-amd64.tar.gz \
38
- && tar -xzf oauth2-proxy-v7.6.0.linux-amd64.tar.gz \
39
- && mv oauth2-proxy-v7.6.0.linux-amd64/oauth2-proxy /usr/bin/oauth2-proxy \
40
  && chmod +x /usr/bin/oauth2-proxy \
41
  && rm -rf oauth2-proxy-v7.6.0.linux-amd64*
42
 
43
- # Install Node.js AND OpenClaw globally
44
- RUN curl -fsSL https://deb.nodesource.com/setup_22.x | bash - && \
45
- apt-get install -y nodejs && \
46
- npm install -g openclaw@latest --unsafe-perm
 
47
 
48
- # Create a non-root user 'user' (UID 1000)
49
- RUN useradd -m -u 1000 user && \
50
- echo 'user ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
 
51
 
52
- # Set up Nginx directories and permissions
53
- RUN mkdir -p /var/www/html/game && \
54
- mkdir -p /var/www/html/theme && \
55
- chown -R user:user /var/www/html && \
56
- chown -R user:user /var/log/nginx && \
57
- chown -R user:user /var/lib/nginx && \
58
- chown -R user:user /etc/nginx
59
-
60
- # Switch to non-root user
61
- WORKDIR $HOME
62
  USER user
 
63
 
64
- # Copy configuration files
65
- COPY --chown=user:user nginx.conf /etc/nginx/nginx.conf
66
- COPY --chown=user:user oauth2-proxy.cfg .
67
- COPY --chown=user:user start.sh .
68
- COPY --chown=user:user sign_in.html /var/www/html/theme/sign_in.html
69
-
70
- RUN chmod +x start.sh
71
-
72
- # Expose port 7860 (Standard for Hugging Face Spaces)
73
  EXPOSE 7860
74
 
75
- # Start services
76
  CMD ["./start.sh"]
 
1
+ # Use a lightweight Debian base
2
  FROM debian:bookworm-slim
3
 
4
+ # Set environment variables
5
  ENV DEBIAN_FRONTEND=noninteractive
6
  ENV HOME=/home/user
7
+ ENV PATH=/usr/local/bin:$HOME/.local/bin:$PATH
8
 
9
+ # 1. 安装基础工具和依赖
10
  RUN apt-get update && apt-get install -y \
11
+ curl wget git sudo vim nano unzip procps net-tools \
12
+ netcat-openbsd build-essential cmake pkg-config python3 \
13
+ nginx xz-utils bzip2 ca-certificates \
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
  && apt-get clean && rm -rf /var/lib/apt/lists/*
15
 
16
+ # 2. 安装 Node.js 20.x (OpenClaw 强依赖)
17
+ RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
18
+ && apt-get install -y nodejs \
19
+ && apt-get clean && rm -rf /var/lib/apt/lists/*
20
+
21
+ # 3. 全局安装 OpenClaw (加上 --unsafe-perm 防止权限报错)
22
+ RUN npm install -g openclaw@latest --unsafe-perm
23
+
24
+ # 4. 安装 ttyd
25
  RUN wget https://github.com/tsl0922/ttyd/releases/download/1.7.7/ttyd.x86_64 -O /usr/bin/ttyd \
26
  && chmod +x /usr/bin/ttyd
27
 
28
+ # 5. 安装 oauth2-proxy (修复了您之前截断的下载逻辑)
 
29
  RUN wget https://github.com/oauth2-proxy/oauth2-proxy/releases/download/v7.6.0/oauth2-proxy-v7.6.0.linux-amd64.tar.gz \
30
+ && tar -xzvf oauth2-proxy-v7.6.0.linux-amd64.tar.gz \
31
+ && mv oauth2-proxy-v7.6.0.linux-amd64/oauth2-proxy /usr/bin/ \
32
  && chmod +x /usr/bin/oauth2-proxy \
33
  && rm -rf oauth2-proxy-v7.6.0.linux-amd64*
34
 
35
+ # 6. 配置非 root 用户 (提升安全性,适配 Hugging Face 等平台)
36
+ RUN useradd -m -s /bin/bash user \
37
+ && echo "user ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers \
38
+ && mkdir -p /var/log/nginx /var/lib/nginx /run/nginx \
39
+ && chown -R user:user /var/log/nginx /var/lib/nginx /run/nginx /etc/nginx
40
 
41
+ # 7. 拷贝启动脚本和配置文件
42
+ # COPY nginx.conf /etc/nginx/nginx.conf <-- 确保您有这个文件
43
+ COPY start.sh /home/user/start.sh
44
+ RUN chmod +x /home/user/start.sh && chown user:user /home/user/start.sh
45
 
46
+ # 切换到非 root 用户
 
 
 
 
 
 
 
 
 
47
  USER user
48
+ WORKDIR /home/user
49
 
50
+ # 暴露 Nginx 端口
 
 
 
 
 
 
 
 
51
  EXPOSE 7860
52
 
 
53
  CMD ["./start.sh"]