# tradingSystem (PMS) 运行镜像
# 三个服务 (pms-web / pms-beat / pms-worker) 共用本镜像, 由 docker-compose 以不同 command 启动
FROM python:3.11-slim

ENV TZ=Asia/Shanghai \
    PYTHONUNBUFFERED=1 \
    PYTHONDONTWRITEBYTECODE=1

# 国内构建默认走清华 PyPI 镜像; 网络环境不同可覆盖:
#   docker compose build --build-arg PIP_INDEX_URL=https://pypi.org/simple
ARG PIP_INDEX_URL=https://pypi.tuna.tsinghua.edu.cn/simple

RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
    && echo "Asia/Shanghai" > /etc/timezone

WORKDIR /app

# 依赖层单独 COPY, 代码改动不触发重装依赖
COPY requirements.txt .
RUN pip install --no-cache-dir -i ${PIP_INDEX_URL} -r requirements.txt

COPY . .

RUN mkdir -p /app/logs

# 默认命令 = 管理页面; beat/worker 由 compose 覆盖 command
CMD ["uvicorn", "app.web.main:app", "--host", "0.0.0.0", "--port", "38100"]
