fix:批量修复了一些问题
This commit is contained in:
+5
-5
@@ -8,11 +8,11 @@ ENV PIP_INDEX_URL=https://pypi.tuna.tsinghua.edu.cn/simple
|
||||
# P2-5: 创建非 root 用户(容器安全最佳实践)
|
||||
RUN groupadd --system profeto && useradd --system --gid profeto profeto
|
||||
|
||||
RUN pip install --no-cache-dir hatchling
|
||||
# Fix 1: 不再复制 README.md(.dockerignore 排除了 *.md)
|
||||
COPY pyproject.toml ./
|
||||
COPY src ./src
|
||||
# 可复现构建:先安装锁定版本的依赖(含哈希校验),再安装本项目
|
||||
COPY pyproject.toml requirements.txt ./
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
COPY src ./src
|
||||
RUN pip install --no-cache-dir .
|
||||
|
||||
# 将工作目录所有权移交给非 root 用户
|
||||
@@ -23,5 +23,5 @@ EXPOSE 8000
|
||||
# 以非 root 用户运行
|
||||
USER profeto
|
||||
|
||||
# Fix 3: 启动时先跑迁移,再启 uvicorn
|
||||
# 启动时先跑迁移,再启 uvicorn
|
||||
CMD ["sh", "-c", "alembic upgrade head && uvicorn src.api.app:app --host 0.0.0.0 --port 8000"]
|
||||
|
||||
Reference in New Issue
Block a user