-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
42 lines (30 loc) · 813 Bytes
/
Copy pathDockerfile
File metadata and controls
42 lines (30 loc) · 813 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# 构建阶段
FROM node:22-alpine AS builder
# 设置工作目录
WORKDIR /app
# 复制 package.json 和 package-lock.json
COPY package*.json ./
# 安装依赖
RUN npm config set registry https://registry.npmmirror.com && npm ci
# 复制源代码
COPY . .
# 构建应用
RUN npm run build
# 生产阶段
FROM node:22-alpine AS runner
# 设置工作目录
WORKDIR /app
# 设置环境变量
ENV NODE_ENV=production
ENV HOST=0.0.0.0
ENV PORT=3000
# 复制构建产物和必要文件
COPY --from=builder /app/.output ./.output
COPY --from=builder /app/package*.json ./
COPY --from=builder /app/ecosystem.config.cjs ./
# 安装生产依赖
RUN npm config set registry https://registry.npmmirror.com && npm ci --production
# 暴露端口
EXPOSE 3000
# 启动应用
CMD ["node", ".output/server/index.mjs"]