clash-linux commited on
Commit
f4f961b
·
verified ·
1 Parent(s): e47cff1

Upload 17 files

Browse files
Files changed (2) hide show
  1. Dockerfile +10 -20
  2. requirements.txt +1 -0
Dockerfile CHANGED
@@ -5,7 +5,7 @@ FROM python:3.9-alpine
5
  WORKDIR /app
6
 
7
  # 安装系统依赖
8
- # 添加 py3-yaml 直接通过 apk 安装 PyYAML
9
  RUN apk add --no-cache \
10
  curl \
11
  ca-certificates \
@@ -16,12 +16,12 @@ RUN apk add --no-cache \
16
  musl-dev \
17
  libffi-dev \
18
  yaml-dev \
19
- py3-yaml \
 
20
  # 添加调试工具
21
  file \
22
  libc-utils \
23
  strace
24
- # 不再需要 build-base,因为不再编译 PyYAML
25
 
26
  # 设置时区为亚洲/上海
27
  ENV TZ=Asia/Shanghai
@@ -70,26 +70,16 @@ COPY requirements.txt ./
70
  # 升级 pip
71
  RUN pip install --upgrade pip
72
 
73
- # 不再需要预安装 Cython 和 setuptools
74
- # RUN pip install --no-cache-dir Cython setuptools
 
75
 
76
- # 不再需要设置 PyYAML 环境变量
77
- # ENV YAML_INCLUDE_DIR=/usr/include \
78
- # YAML_LIB_DIR=/usr/lib
79
-
80
- # 不再需要单独安装 PyYAML
81
- # RUN echo "Installing PyYAML..." && \
82
- # pip install --no-cache-dir --no-build-isolation PyYAML==6.0
83
-
84
- # 安装剩余的Python依赖 (PyYAML 已通过 apk 安装)
85
  RUN echo "Installing Python dependencies..." && \
86
  pip install --no-cache-dir -r requirements.txt
87
 
88
- # 确保安装PyYAML
89
- # RUN pip install --no-cache-dir pyyaml
90
-
91
  # 可选:删除构建依赖以减小镜像体积
92
- # RUN apk del python3-dev musl-dev libffi-dev yaml-dev
93
 
94
  # 设置环境变量
95
  ENV PYTHONDONTWRITEBYTECODE=1 \
@@ -108,8 +98,8 @@ COPY app/ ./app/
108
  COPY entrypoint.sh ./
109
  RUN chmod +x ./entrypoint.sh
110
 
111
- # 给脚本和二进制文件执行权限
112
- RUN chmod +x ./clash_core/clash.meta-linux-amd64 ./clash_core/clash.meta-linux-amd64-v1.14.5 || true
113
  RUN chmod +x ./subconverter/subconverter || true
114
 
115
  # 暴露端口
 
5
  WORKDIR /app
6
 
7
  # 安装系统依赖
8
+ # 添加 yaml-dev 提供编译PyYAML所需的libyaml
9
  RUN apk add --no-cache \
10
  curl \
11
  ca-certificates \
 
16
  musl-dev \
17
  libffi-dev \
18
  yaml-dev \
19
+ # 不再需要 py3-yaml
20
+ # py3-yaml \
21
  # 添加调试工具
22
  file \
23
  libc-utils \
24
  strace
 
25
 
26
  # 设置时区为亚洲/上海
27
  ENV TZ=Asia/Shanghai
 
70
  # 升级 pip
71
  RUN pip install --upgrade pip
72
 
73
+ # 安装Cython(用于编译PyYAML)
74
+ RUN echo "Installing Cython for PyYAML build..." && \
75
+ pip install --no-cache-dir Cython
76
 
77
+ # 安装Python依赖(包括PyYAML,现在应该能成功编译了)
 
 
 
 
 
 
 
 
78
  RUN echo "Installing Python dependencies..." && \
79
  pip install --no-cache-dir -r requirements.txt
80
 
 
 
 
81
  # 可选:删除构建依赖以减小镜像体积
82
+ RUN apk del python3-dev musl-dev libffi-dev yaml-dev
83
 
84
  # 设置环境变量
85
  ENV PYTHONDONTWRITEBYTECODE=1 \
 
98
  COPY entrypoint.sh ./
99
  RUN chmod +x ./entrypoint.sh
100
 
101
+ # 给脚本和二进制文件执行权限 (重复的chmod可能不需要,但在构建阶段设置更安全)
102
+ RUN chmod +x ./clash_core/clash.meta-linux-amd64 || true
103
  RUN chmod +x ./subconverter/subconverter || true
104
 
105
  # 暴露端口
requirements.txt CHANGED
@@ -2,5 +2,6 @@ flask==2.0.1
2
  gunicorn==20.1.0
3
  requests==2.28.1
4
  Werkzeug==2.0.1
 
5
  # pyyaml==6.0 # 已通过 apk 安装
6
  # 添加与 Flask==2.0.1 兼容的版本
 
2
  gunicorn==20.1.0
3
  requests==2.28.1
4
  Werkzeug==2.0.1
5
+ PyYAML==6.0.1
6
  # pyyaml==6.0 # 已通过 apk 安装
7
  # 添加与 Flask==2.0.1 兼容的版本