fix(docker): align customer image build
This commit is contained in:
@@ -0,0 +1,18 @@
|
|||||||
|
.git
|
||||||
|
.github
|
||||||
|
.gitea
|
||||||
|
__pycache__/
|
||||||
|
.pytest_cache/
|
||||||
|
.mypy_cache/
|
||||||
|
.venv/
|
||||||
|
venv/
|
||||||
|
build/
|
||||||
|
dist/
|
||||||
|
package/
|
||||||
|
temp/
|
||||||
|
data/
|
||||||
|
# db_inp/
|
||||||
|
inp/
|
||||||
|
# .env
|
||||||
|
*.pyc
|
||||||
|
*.dump
|
||||||
+11
-7
@@ -1,21 +1,25 @@
|
|||||||
FROM continuumio/miniconda3:latest
|
FROM condaforge/miniforge3:latest
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
|
ENV PIP_INDEX_URL=https://pypi.tuna.tsinghua.edu.cn/simple \
|
||||||
|
PIP_TRUSTED_HOST=pypi.tuna.tsinghua.edu.cn \
|
||||||
|
UV_INDEX_URL=https://pypi.tuna.tsinghua.edu.cn/simple
|
||||||
|
|
||||||
# 安装 Python 3.12 和 pymetis (通过 conda-forge 避免编译问题)
|
# 安装 Python 3.12 和 pymetis (通过 conda-forge 避免编译问题)
|
||||||
RUN conda install -y -c conda-forge python=3.12 pymetis && \
|
RUN mamba install -y python=3.12 pymetis && \
|
||||||
conda clean -afy
|
mamba clean -afy
|
||||||
|
|
||||||
COPY requirements.txt .
|
COPY requirements.txt .
|
||||||
RUN pip install uv
|
RUN pip install --no-cache-dir uv
|
||||||
RUN uv pip install --no-cache-dir -r requirements.txt
|
RUN uv pip install --system --no-cache-dir -r requirements.txt
|
||||||
|
|
||||||
# 将代码放入子目录 'app',将数据放入子目录 'db_inp'
|
# 将代码放入子目录 'app',将数据放入子目录 'db_inp'
|
||||||
# 这样临时文件默认会生成在 /app 下,而代码在 /app/app 下,实现了分离
|
# 这样临时文件默认会生成在 /app 下,而代码在 /app/app 下,实现了分离
|
||||||
COPY app ./app
|
COPY app ./app
|
||||||
COPY db_inp ./db_inp
|
# COPY db_inp ./db_inp
|
||||||
COPY temp ./temp
|
|
||||||
COPY .env .
|
COPY .env .
|
||||||
|
RUN mkdir -p db_inp temp data inp
|
||||||
|
|
||||||
# 设置 PYTHONPATH 以便 uvicorn 找到 app 模块
|
# 设置 PYTHONPATH 以便 uvicorn 找到 app 模块
|
||||||
ENV PYTHONPATH=/app
|
ENV PYTHONPATH=/app
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ services:
|
|||||||
api:
|
api:
|
||||||
build:
|
build:
|
||||||
context: ../..
|
context: ../..
|
||||||
dockerfile: infra/docker/Dockerfile
|
dockerfile: Dockerfile
|
||||||
container_name: tjwater_api
|
container_name: tjwater_api
|
||||||
restart: always
|
restart: always
|
||||||
ports:
|
ports:
|
||||||
|
|||||||
Reference in New Issue
Block a user