upload Dockerfile

This commit is contained in:
LibraHp_0928 2024-10-13 15:31:38 +08:00
parent 5fc241088b
commit 5b2035a4ee
4 changed files with 60 additions and 1 deletions

33
Dockerfile Normal file
View File

@ -0,0 +1,33 @@
# 使用官方 Python 基础镜像
FROM python:3.9-slim
# 设置工作目录
WORKDIR /app
# 复制本地的依赖文件和应用程序文件到容器中
COPY requirements.txt ./
COPY main.py ./
# 安装依赖项,并指定 pip 源
RUN python -m venv /app/.venv && \
/app/.venv/bin/pip install -i https://mirrors.aliyun.com/pypi/simple/ --upgrade pip && \
/app/.venv/bin/pip install -i https://mirrors.aliyun.com/pypi/simple/ -r requirements.txt
RUN apt-get update && apt-get install -y libgtk-3-0
# 安装 NGINX
RUN apt-get update && apt-get install -y nginx && \
rm /etc/nginx/sites-enabled/default
# 复制 NGINX 配置文件
COPY nginx.conf /etc/nginx/conf.d/default.conf
# 设置环境变量
ENV PATH="/app/.venv/bin:$PATH"
ENV FLET_SERVER_PORT=8000
# 开放端口
EXPOSE 80
# 启动 Flet 和 NGINX
CMD service nginx start && python main.py

View File

@ -141,7 +141,7 @@ def log(message,type="info"):
now = time.strftime("%Y-%m-%d %H:%M:%S")
log_info_ref.current.value = f"[{now}] - {message}"
# 写入日志到文件
with open(f"{save_path}/log.txt", "a", encoding="utf-8") as f:
with open(f"log.txt", "a", encoding="utf-8") as f:
f.write(f"[{now}] - {message}\n")
if type == "success":
log_info_ref.current.color = "green"

25
nginx.conf Normal file
View File

@ -0,0 +1,25 @@
server {
listen 80;
location / {
proxy_pass http://127.0.0.1:8000/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection keep-alive;
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
location /ws {
proxy_pass http://127.0.0.1:8000/ws;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}

View File

@ -1,3 +1,4 @@
beautifulsoup4==4.12.2
flet==0.24.1
pandas==2.2.3
Requests==2.31.0