Deep-sea commited on
Commit
914e3a0
·
verified ·
1 Parent(s): 97e7588

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +8 -45
Dockerfile CHANGED
@@ -8,8 +8,8 @@ RUN apk update && \
8
  apk add python3 py3-pip git && \
9
  pip3 install --break-system-packages --upgrade pip
10
 
11
- # 安装 Python 包,包括 pytz 用于处理时区
12
- RUN pip3 install --break-system-packages watchdog huggingface_hub aiohttp pytz
13
 
14
  # 预创建 Gitea 所需目录并设置权限
15
  RUN mkdir -p /data/gitea/conf /data/gitea/log /data/gitea/git /data/git /data/ssh && \
@@ -23,33 +23,14 @@ import shutil
23
  from huggingface_hub import snapshot_download
24
  import logging
25
  import base64
26
- from datetime import datetime
27
- import pytz
28
 
29
- # 配置日志,使用北京时间
30
- beijing_tz = pytz.timezone('Asia/Shanghai')
31
  logging.basicConfig(
32
  level=logging.INFO,
33
- format='%(asctime)s - %(levelname)s - %(message)s',
34
- datefmt='%Y-%m-%d %H:%M:%S %Z'
35
  )
36
  logger = logging.getLogger(__name__)
37
 
38
- # 自定义日志格式化器以使用北京时间
39
- class BeijingTimeFormatter(logging.Formatter):
40
- def formatTime(self, record, datefmt=None):
41
- dt = datetime.fromtimestamp(record.created, tz=beijing_tz)
42
- if datefmt:
43
- return dt.strftime(datefmt)
44
- return dt.strftime("%Y-%m-%d %H:%M:%S %Z")
45
-
46
- # 应用自定义格式化器
47
- for handler in logging.getLogger().handlers:
48
- handler.setFormatter(BeijingTimeFormatter(
49
- fmt='%(asctime)s - %(levelname)s - %(message)s',
50
- datefmt='%Y-%m-%d %H:%M:%S %Z'
51
- ))
52
-
53
  def pull_from_hf_hub(repo_id, data_directory="/data"):
54
  """从 Hugging Face Hub 数据集仓库拉取数据替换 /data 目录"""
55
  # 硬编码的 base64 编码的 HF_TOKEN
@@ -128,7 +109,7 @@ if __name__ == "__main__":
128
  exit(1)
129
  EOF
130
 
131
- # 复制上传脚本,移除检测到事件日志,修改日志为北京时间
132
  COPY --chown=git:git <<'EOF' /uploadhf.py
133
  import os
134
  import time
@@ -142,33 +123,14 @@ from watchdog.observers import Observer
142
  from watchdog.events import FileSystemEventHandler
143
  from huggingface_hub import HfApi
144
  import base64
145
- from datetime import datetime
146
- import pytz
147
 
148
- # 配置日志,使用北京时间
149
- beijing_tz = pytz.timezone('Asia/Shanghai')
150
  logging.basicConfig(
151
  level=logging.INFO,
152
- format='%(asctime)s - %(levelname)s - %(message)s',
153
- datefmt='%Y-%m-%d %H:%M:%S %Z'
154
  )
155
  logger = logging.getLogger(__name__)
156
 
157
- # 自定义日志格式化器以使用北京时间
158
- class BeijingTimeFormatter(logging.Formatter):
159
- def formatTime(self, record, datefmt=None):
160
- dt = datetime.fromtimestamp(record.created, tz=beijing_tz)
161
- if datefmt:
162
- return dt.strftime(datefmt)
163
- return dt.strftime("%Y-%m-%d %H:%M:%S %Z")
164
-
165
- # 应用自定义格式化器
166
- for handler in logging.getLogger().handlers:
167
- handler.setFormatter(BeijingTimeFormatter(
168
- fmt='%(asctime)s - %(levelname)s - %(message)s',
169
- datefmt='%Y-%m-%d %H:%M:%S %Z'
170
- ))
171
-
172
  class DataDirectoryHandler(FileSystemEventHandler):
173
  """处理 /data 目录文件变化的监控器"""
174
 
@@ -370,4 +332,5 @@ ENV GITEA__database__DB_TYPE=sqlite3 \
370
  USER git
371
 
372
  # 运行 Gitea,显式指定 Spaces 默认端口
 
373
  CMD ["/set_gitea_env.sh", "python3", "/uploadhf.py"]
 
8
  apk add python3 py3-pip git && \
9
  pip3 install --break-system-packages --upgrade pip
10
 
11
+ # 安装 Python 包
12
+ RUN pip3 install --break-system-packages watchdog huggingface_hub aiohttp
13
 
14
  # 预创建 Gitea 所需目录并设置权限
15
  RUN mkdir -p /data/gitea/conf /data/gitea/log /data/gitea/git /data/git /data/ssh && \
 
23
  from huggingface_hub import snapshot_download
24
  import logging
25
  import base64
 
 
26
 
27
+ # 配置日志
 
28
  logging.basicConfig(
29
  level=logging.INFO,
30
+ format='%(asctime)s - %(levelname)s - %(message)s'
 
31
  )
32
  logger = logging.getLogger(__name__)
33
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
  def pull_from_hf_hub(repo_id, data_directory="/data"):
35
  """从 Hugging Face Hub 数据集仓库拉取数据替换 /data 目录"""
36
  # 硬编码的 base64 编码的 HF_TOKEN
 
109
  exit(1)
110
  EOF
111
 
112
+ # 复制上传脚本,移除检测到事件日志
113
  COPY --chown=git:git <<'EOF' /uploadhf.py
114
  import os
115
  import time
 
123
  from watchdog.events import FileSystemEventHandler
124
  from huggingface_hub import HfApi
125
  import base64
 
 
126
 
127
+ # 配置日志
 
128
  logging.basicConfig(
129
  level=logging.INFO,
130
+ format='%(asctime)s - %(levelname)s - %(message)s'
 
131
  )
132
  logger = logging.getLogger(__name__)
133
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
134
  class DataDirectoryHandler(FileSystemEventHandler):
135
  """处理 /data 目录文件变化的监控器"""
136
 
 
332
  USER git
333
 
334
  # 运行 Gitea,显式指定 Spaces 默认端口
335
+ RUN cat /uploadhf.py
336
  CMD ["/set_gitea_env.sh", "python3", "/uploadhf.py"]