# 生产镜像：ffmpeg + 多阶段构建 Next 静态页 + Python API（默认端口 8101，减少与同机 SRS/代理 冲突）
# docker compose up --build
FROM node:20-bookworm-slim AS console
WORKDIR /src/web-console
COPY web-console/package.json web-console/package-lock.json ./
RUN npm ci
COPY web-console/ ./
RUN npm run build

FROM python:3.12-slim-bookworm
WORKDIR /app
ENV PYTHONDONTWRITEBYTECODE=1 \
    PIP_NO_CACHE_DIR=1 \
    PORT=8101

RUN apt-get update \
    && apt-get install -y --no-install-recommends ffmpeg ca-certificates \
    && rm -rf /var/lib/apt/lists/* \
    && ffmpeg -version

COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

COPY . .
COPY --from=console /src/web-console/out ./web-console/out

EXPOSE 8101
CMD ["sh", "-c", "exec python -m uvicorn web:app --host 0.0.0.0 --port ${PORT}"]
