feat: 增加 Metrix 应用包打包脚本并完善容器镜像

This commit is contained in:
2026-11-03 12:33:02 +08:00
parent 5d4b86c558
commit 2f986bd2c3
3 changed files with 144 additions and 4 deletions
+10 -4
View File
@@ -2,19 +2,25 @@ ARG NODE_IMAGE=node:22-bookworm-slim
ARG PYTHON_IMAGE=python:3.13-slim
FROM ${NODE_IMAGE} AS web
ARG NPM_REGISTRY=
WORKDIR /src
COPY web/package.json web/package-lock.json ./
RUN npm ci
RUN if [ -n "$NPM_REGISTRY" ]; then npm config set registry "$NPM_REGISTRY"; fi \
&& npm ci --no-audit --no-fund
COPY web/ .
RUN npm run build
FROM ${PYTHON_IMAGE}
ARG PIP_INDEX=
WORKDIR /app
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1
PYTHONUNBUFFERED=1 \
PIP_DISABLE_PIP_VERSION_CHECK=1 \
DECOM_INLINE_WORKER=0
COPY backend/requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
RUN if [ -n "$PIP_INDEX" ]; then pip install --no-cache-dir --index-url "$PIP_INDEX" -r requirements.txt; \
else pip install --no-cache-dir -r requirements.txt; fi
COPY backend/ .
COPY --from=web /src/dist ./web/dist
EXPOSE 8000
CMD ["python", "-m", "uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]
CMD ["python", "-m", "uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000", "--forwarded-allow-ips", "*"]