timmy commited on
Commit
5ecb8d1
·
1 Parent(s): 1a0f6ab
Files changed (4) hide show
  1. Dockerfile +12 -12
  2. README.md +1 -0
  3. dante.template.conf +0 -16
  4. entrypoint.sh +0 -31
Dockerfile CHANGED
@@ -1,16 +1,16 @@
1
- FROM dperson/dante:latest
 
2
 
3
- # 设置环境变量,默认用户名密码,如果容器启动时未传入,可用 entrypoint 脚本生成随机
4
- ENV USERNAME=""
5
- ENV PASSWORD=""
6
 
7
- # 复制 entrypoint 脚本
8
- COPY entrypoint.sh /entrypoint.sh
9
- RUN chmod +x /entrypoint.sh
10
 
11
- # 暴露 SOCKS5 端口
12
- EXPOSE 7860
13
 
14
- # 启动容器时执行 entrypoint
15
- ENTRYPOINT ["/entrypoint.sh"]
16
- CMD []
 
 
 
1
+ # Read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker
2
+ # you will also find guides on how best to write your Dockerfile
3
 
4
+ FROM python:3.9
 
 
5
 
6
+ RUN useradd -m -u 1000 user
7
+ USER user
8
+ ENV PATH="/home/user/.local/bin:$PATH"
9
 
10
+ WORKDIR /app
 
11
 
12
+ COPY --chown=user ./requirements.txt requirements.txt
13
+ RUN pip install --no-cache-dir --upgrade -r requirements.txt
14
+
15
+ COPY --chown=user . /app
16
+ CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8080"]
README.md CHANGED
@@ -5,6 +5,7 @@ colorFrom: red
5
  colorTo: green
6
  sdk: docker
7
  pinned: false
 
8
  ---
9
 
10
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
5
  colorTo: green
6
  sdk: docker
7
  pinned: false
8
+ app_port: 8080
9
  ---
10
 
11
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
dante.template.conf DELETED
@@ -1,16 +0,0 @@
1
- logoutput: stderr
2
-
3
- internal: 0.0.0.0 port = 1080
4
-
5
- __EXTERNAL_INTERFACE__
6
-
7
- method: username
8
- user.notprivileged: nobody
9
-
10
- client pass {
11
- from: 0.0.0.0/0 to: 0.0.0.0/0
12
- }
13
-
14
- socks pass {
15
- from: 0.0.0.0/0 to: 0.0.0.0/0
16
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
entrypoint.sh DELETED
@@ -1,31 +0,0 @@
1
- #!/bin/bash
2
-
3
- echo ">>> Detecting network interface..."
4
- IFACE=$(ip route get 8.8.8.8 | awk '{print $5; exit}')
5
- echo ">>> Detected external interface: $IFACE"
6
-
7
- # 自动生成账号密码
8
- if [ -z "$USERNAME" ]; then
9
- USERNAME="user$(date +%s | md5sum | cut -c1-5)"
10
- fi
11
-
12
- if [ -z "$PASSWORD" ]; then
13
- PASSWORD="$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 10)"
14
- fi
15
-
16
- echo ">>> SOCKS Username: $USERNAME"
17
- echo ">>> SOCKS Password: $PASSWORD"
18
-
19
- # 创建系统用户
20
- useradd -r -s /bin/false "$USERNAME"
21
- echo "$USERNAME:$PASSWORD" | chpasswd
22
-
23
- # 生成最终配置文件
24
- sed "s|__EXTERNAL_INTERFACE__|external: $IFACE|" \
25
- /etc/dante.template.conf > /etc/dante.conf
26
-
27
- echo ">>> Final /etc/dante.conf:"
28
- cat /etc/dante.conf
29
-
30
- echo ">>> Starting Dante SOCKS5..."
31
- exec /usr/sbin/sockd -f /etc/dante.conf