charlielin0121 commited on
Commit
b331fd5
·
verified ·
1 Parent(s): 7acd13a

Create Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +37 -0
Dockerfile ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 使用 Ubuntu 22.04 作為基底系統
2
+ FROM ubuntu:22.04
3
+
4
+ # 設定非互動模式,避免安裝過程卡住
5
+ ENV DEBIAN_FRONTEND=noninteractive
6
+
7
+ # 1. 安裝常用工具 (curl, git, vim 等)
8
+ # 2. 下載 ttyd (這是核心工具)
9
+ RUN apt-get update && apt-get install -y \
10
+ curl \
11
+ wget \
12
+ git \
13
+ vim \
14
+ nano \
15
+ sudo \
16
+ net-tools \
17
+ iputils-ping \
18
+ && rm -rf /var/lib/apt/lists/* \
19
+ && wget -O /usr/local/bin/ttyd https://github.com/tsl0922/ttyd/releases/download/1.7.7/ttyd.x86_64 \
20
+ && chmod +x /usr/local/bin/ttyd
21
+
22
+ # 建立一個名叫 'user' 的使用者,並給予 sudo 權限 (免密碼)
23
+ RUN useradd -m -s /bin/bash user && \
24
+ echo "user ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/nopasswd
25
+
26
+ # 切換到該使用者
27
+ USER user
28
+ WORKDIR /home/user
29
+
30
+ # Hugging Face Spaces 預設 Port
31
+ EXPOSE 7860
32
+
33
+ # 啟動 ttyd
34
+ # -W: 允許寫入 (可以輸入指令)
35
+ # -p 7860: 指定 Port
36
+ # bash: 執行的 Shell
37
+ CMD ["ttyd", "-W", "-p", "7860", "bash"]