Files
estel_docs/Dockerfile
2025-07-29 00:38:01 +08:00

44 lines
1008 B
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.

########## 阶段 1build ##########
FROM node:20-alpine AS base
# 1. 如项目有原生包better-sqlite3、sharp等启用下面两行
# RUN apk add --no-cache build-base python3 sqlite-dev
# 安装pnpm
RUN npm install -g pnpm
WORKDIR /app
# 2. 用 pnpm 锁文件
COPY package.json pnpm-lock.yaml ./
RUN pnpm install --frozen-lockfile
# 3. 源码 + 打补丁
COPY . .
RUN chmod +x patch-ui-pro.zsh && ./patch-ui-pro.zsh
# 4. 构建产物
RUN pnpm build
########## 阶段 2生产运行时 ##########
FROM node:20-alpine AS production
# 安装pnpm
RUN npm install -g pnpm
# 输出里有 .outputNuxt3 的默认路径
WORKDIR /app
# 1. 如果项目由 better-sqlite3运行时还需 sqlite-libs
# RUN apk add --no-cache sqlite-libs
# 2. 只拷贝生产运行时
COPY package.json pnpm-lock.yaml ./
RUN pnpm install --frozen-lockfile --prod
COPY --from=base /app/.output /app/.output
EXPOSE 3000
ENV NODE_ENV=production HOST=0.0.0.0 PORT=3000
CMD ["node", ".output/server/index.mjs"]