Skip to content
This repository was archived by the owner on Feb 11, 2026. It is now read-only.

Commit 6d1885d

Browse files
authored
Refactor Dockerfile for pnpm and entry point fix
Updated Dockerfile to use pnpm for production dependencies and corrected the entry point for AdonisJS.
1 parent d725e25 commit 6d1885d

1 file changed

Lines changed: 15 additions & 11 deletions

File tree

Dockerfile

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,34 @@
1+
# --- 阶段 1: 基础环境 ---
12
FROM node:22.16.0-alpine3.22 AS base
23
RUN corepack enable && corepack prepare pnpm@latest --activate
34
WORKDIR /app
4-
# All deps stage
5+
6+
# --- 阶段 2: 安装所有依赖 (用于 Build) ---
57
FROM base AS deps
68
COPY package.json pnpm-lock.yaml ./
7-
# 使用 --frozen-lockfile 确保安装与锁定文件完全一致
89
RUN pnpm install --frozen-lockfile
910

10-
# Production only deps stage
11+
# --- 阶段 3: 仅安装生产环境依赖 ---
1112
FROM base AS production-deps
12-
WORKDIR /app
13-
ADD package.json package-lock.json ./
14-
RUN npm ci --omit=dev
13+
COPY package.json pnpm-lock.yaml ./
14+
# 修正点:使用 pnpm 只安装生产依赖
15+
RUN pnpm install --prod --frozen-lockfile
1516

16-
# Build stage
17+
# --- 阶段 4: 编译阶段 ---
1718
FROM base AS build
18-
WORKDIR /app
1919
COPY --from=deps /app/node_modules /app/node_modules
2020
ADD . .
2121
RUN node ace build
2222

23-
# Production stage
24-
FROM base
23+
# --- 阶段 5: 最终运行阶段 ---
24+
FROM node:22.16.0-alpine3.22
2525
ENV NODE_ENV=production
2626
WORKDIR /app
27+
# 从阶段 3 拷贝生产依赖
2728
COPY --from=production-deps /app/node_modules /app/node_modules
29+
# 从阶段 4 拷贝编译后的产物
2830
COPY --from=build /app/build /app
2931
EXPOSE 3000
30-
CMD ["node", "./bin/server.js"]
32+
33+
# 修正点:AdonisJS 编译后的入口路径
34+
CMD ["node", "bin/server.js"]

0 commit comments

Comments
 (0)