浏览代码

feat:修改Dockerfile

ZhaoHP 1 周之前
父节点
当前提交
7f0da1ca4d
共有 3 个文件被更改,包括 47 次插入3 次删除
  1. 1 2
      Dockerfile
  2. 45 0
      README-run.md
  3. 1 1
      app.py

+ 1 - 2
Dockerfile

@@ -19,8 +19,7 @@ ENV PATH="/root/.local/bin:${PATH}"
 # 复制项目文件
 COPY . /app
 
-# 安装uv
-RUN uv lock -i https://mirrors.aliyun.com/pypi/simple/
+# 安装uv依赖
 RUN uv sync --frozen -i https://mirrors.aliyun.com/pypi/simple/
 
 # 暴露服务端口(FastAPI 默认 5344)

+ 45 - 0
README-run.md

@@ -1,3 +1,48 @@
+### 说明
+
+项目使用的基础镜像基于官方的python:3.12-slim镜像生成,里面安装了uv,修改了uv的镜像源配置
+
+##### /root/.config/uv/uv.toml 内容
+
+```toml
+[[index]]
+url = "https://mirrors.aliyun.com/pypi/simple/"
+default = true
+```
+
+#### 镜像构建
+
+```shell
+cd /root/workspace/SoraWatermarkCleaner
+docker build -t sorawm:{tag} .
+```
+
+tag建议使用yyyyMMddHHmmss的形式生成 \
+项目最终生成的镜像文件比较大,将近9个G,与.venv环境有关,后续考虑优化
+
+#### 生成uv.lock
+
+```shell
+RUN uv lock -i https://mirrors.aliyun.com/pypi/simple/
+```
+
+生成uv.lock使用阿里的镜像源,原因: 机器上访问官方的镜像源比较慢,需要换成国内的源。
+
+#### 启动脚本 sorawm_start.sh
+
+```shell
+
+#!/bin/bash
+
+source /app/.venv/bin/activate
+
+uv run streamlit run app.py --server.port 8503 --server.headless true --browser.gatherUsageStats false &
+uv run python start_server.py --host 0.0.0.0 --port 5344 &
+
+wait
+
+```
+
 前端正确启动方式(关闭交互提示,便于自动化预览):
 uv run streamlit run app.py --server.port 8503 --server.headless true --browser.gatherUsageStats false
 后端正确启动方式(关闭交互提示,便于自动化预览):

+ 1 - 1
app.py

@@ -21,7 +21,7 @@ def main():
     use_backend = st.sidebar.checkbox("使用后端服务 (FastAPI)", value=True)
     backend_url = st.sidebar.text_input(
         "后端地址",
-        value="http://localhost:5344",
+        value="http://192.168.245.14:5344",
         help="FastAPI 服务的基础地址",
     )