hts/apps/blogai/Dockerfile

55 lines
1.2 KiB
Docker
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# --- 第一阶段:构建阶段 ---
FROM node:20-bullseye-slim AS builder
ARG BLOGAI_HOST=ai.szaiai.com
ENV NODE_ENV=production
ENV BLOGAI_HOST=${BLOGAI_HOST}
WORKDIR /app
RUN npm install -g pnpm
COPY . ./
COPY apps/blogai/.env.example apps/blogai/.env
RUN sed -i "s|{{BLOGAI_HOST}}|${BLOGAI_HOST}|g" apps/blogai/.env
RUN pnpm install
# ✅ 不再执行 pnpm run build让你手动搞
# WORKDIR /app/apps/blogai
# RUN pnpm run build
# --- 第二阶段:运行阶段 ---
FROM node:20-slim AS runner
ARG BLOGAI_HOST=ai.szaiai.com
ENV NODE_ENV=development
ENV PORT=3008
ENV BLOGAI_HOST=${BLOGAI_HOST}
# 安装常用调试工具
RUN apt-get update && \
apt-get install -y supervisor curl vim bash && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# 设置 supervisor 配置目录(你要调试可以不用 supervisor
RUN mkdir -p /etc/supervisor/conf.d
# 设置工作目录
WORKDIR /plugai
# 拷贝 supervisor.conf 到指定路径
COPY ./supervisor.conf /etc/supervisor/conf.d/supervisor.conf
# 拷贝 node_modules 和源码
COPY --from=builder /app /plugai
# 默认进入 blogai 子项目
WORKDIR /plugai/apps/blogai
# 设置 shell 默认入口
CMD ["/bin/bash"]