修正dockerfile
This commit is contained in:
39
Dockerfile
39
Dockerfile
@@ -1,27 +1,32 @@
|
|||||||
|
# ------------- 依赖缓存阶段 -------------
|
||||||
|
FROM node:22-alpine AS base
|
||||||
|
|
||||||
|
# 国内镜像
|
||||||
|
RUN npm config set registry https://registry.npmmirror.com
|
||||||
|
|
||||||
FROM node:22-alpine
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# RUN npm config set registry https://registry.npmmirror.com
|
# 拷贝所有源码 - Nuxt 4在pnpm i阶段需要完整的项目结构
|
||||||
RUN corepack enable
|
COPY . .
|
||||||
|
|
||||||
# Copy package.json and your lockfile, here we add pnpm-lock.yaml for illustration
|
# 安装依赖
|
||||||
# COPY package.json pnpm-lock.yaml .npmrc ./
|
RUN corepack enable && pnpm install --frozen-lockfile
|
||||||
|
|
||||||
COPY . ./
|
# 执行补丁脚本
|
||||||
|
|
||||||
# Install dependencies
|
|
||||||
RUN pnpm i
|
|
||||||
|
|
||||||
# Copy the entire project
|
|
||||||
# Build the project
|
|
||||||
RUN chmod +x patch-ui-pro.zsh && ./patch-ui-pro.zsh
|
RUN chmod +x patch-ui-pro.zsh && ./patch-ui-pro.zsh
|
||||||
RUN pnpm run build
|
|
||||||
|
|
||||||
# Change the port and host
|
# ------------- 构建阶段 -------------
|
||||||
ENV PORT=3000
|
FROM base AS builder
|
||||||
ENV HOST=0.0.0.0
|
RUN pnpm build
|
||||||
|
|
||||||
|
# ------------- 运行阶段 -------------
|
||||||
|
FROM node:22-alpine AS production
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# 拷贝构建产物 - Nuxt的output目录已经包含了所有运行时需要的文件
|
||||||
|
COPY --from=builder /app/.output ./.output
|
||||||
|
|
||||||
EXPOSE 3000
|
EXPOSE 3000
|
||||||
|
ENV NODE_ENV=production HOST=0.0.0.0 PORT=3000
|
||||||
CMD ["node", ".output/server/index.mjs"]
|
CMD ["node", ".output/server/index.mjs"]
|
Reference in New Issue
Block a user