mirror of
https://github.com/yshtcn/ServerChanPush2TelegramBot.git
synced 2026-01-28 17:42:01 +08:00
### 更新日志 - 2024年6月15日
#### 新增功能 1. **配置文件路径调整**: - `bot_config.json`的读取路径移动到`/data/`目录,`bot_config_example.json`保留在原目录。 - 日志文件存储路径移动到`/data/log/`目录。 2. **目录自动创建**: - 在程序启动时自动创建必要的目录(`/data`和`/data/log`),确保目录存在。 3. **配置文件不存在时自动复制**: - 当`bot_config.json`不存在时,自动将`bot_config_example.json`复制到指定位置,并写入日志,然后退出程序。 4. **API URL和代理配置读取**: - 将`api_url`和`proxies`配置移动到`bot_config.json`中读取,支持灵活配置反向代理。 5. **端口配置支持**: - 支持从配置文件中读取端口配置,默认端口为5000。注意:Docker环境中Gunicorn默认监听5000端口,建议使用端口映射指定端口。 6. **Docker支持**: - 编写Dockerfile以支持Docker环境运行。 - 在Dockerfile中固定Gunicorn监听端口为5000,并确保Gunicorn绑定到`0.0.0.0`,从而对外部可访问。 #### 修复 1. **路径兼容性**: - 修复了Windows环境下目录和文件操作的兼容性问题,确保在不同平台下正常运行。 2. **日志和数据文件存储路径调整**: - 调整`received_data`和`sent_data`文件的存储路径到`/data/log`目录,统一管理日志文件。 #### 优化 1. **代码结构优化**: - 提升了代码的可读性和可维护性,简化了配置文件的读取和日志管理逻辑。
This commit is contained in:
26
Dockerfile
Normal file
26
Dockerfile
Normal file
@@ -0,0 +1,26 @@
|
||||
# Use an official Python runtime as a parent image
|
||||
FROM python:3.12-slim
|
||||
|
||||
# Set the working directory in the container to /app
|
||||
WORKDIR /app
|
||||
|
||||
# Copy only necessary files
|
||||
COPY ServerChanPush2TelegramBot.py /app/
|
||||
COPY wsgi.py /app/
|
||||
COPY bot_config_example.json /app/
|
||||
COPY requirements.txt /app/
|
||||
|
||||
# Install any needed packages specified in requirements.txt
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
# Ensure bot_config.json exists
|
||||
RUN if [ ! -f /app/data/bot_config.json ]; then \
|
||||
mkdir -p /app/data && \
|
||||
cp /app/bot_config_example.json /app/data/bot_config.json; \
|
||||
fi
|
||||
|
||||
# Expose the port
|
||||
EXPOSE 5000
|
||||
|
||||
# Run wsgi server with gunicorn
|
||||
CMD ["gunicorn", "--bind", "0.0.0.0:5000", "wsgi:app"]
|
||||
Reference in New Issue
Block a user