Skip to content

Commit 953393c

Browse files
committed
chore: switch from yarn to npm
1 parent ad8d6fb commit 953393c

2 files changed

Lines changed: 8 additions & 1170 deletions

File tree

Dockerfile

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ WORKDIR /app
88
RUN apk add --no-cache python3 make g++
99

1010
# 复制package文件以优化Docker层缓存
11-
COPY package.json yarn.lock ./
11+
COPY package.json package-lock.json ./
1212

1313
# 安装所有依赖(包括devDependencies)
14-
RUN yarn install --frozen-lockfile --registry https://registry.npmmirror.com/ --ignore-engines
14+
RUN npm ci --registry https://registry.npmmirror.com/
1515

1616
# 复制源代码
1717
COPY . .
@@ -25,7 +25,7 @@ RUN if [ -n "$VERSION" ]; then \
2525
fi
2626

2727
# 构建应用
28-
RUN yarn build
28+
RUN npm run build
2929

3030
# 生产阶段
3131
FROM node:18-alpine AS production
@@ -40,13 +40,13 @@ RUN addgroup -g 1001 -S nodejs && \
4040
# 设置工作目录
4141
WORKDIR /app
4242

43-
# 复制 package.json(使用构建阶段已更新版本)与 yarn.lock
43+
# 复制 package.json(使用构建阶段已更新版本)与 package-lock.json
4444
COPY --from=builder /app/package.json ./package.json
45-
COPY yarn.lock ./
45+
COPY --from=builder /app/package-lock.json ./package-lock.json
4646

4747
# 只安装生产依赖
48-
RUN yarn install --frozen-lockfile --production --registry https://registry.npmmirror.com/ --ignore-engines && \
49-
yarn cache clean
48+
RUN npm ci --omit=dev --registry https://registry.npmmirror.com/ && \
49+
npm cache clean --force
5050

5151
# 从构建阶段复制构建产物
5252
COPY --from=builder --chown=jimeng:nodejs /app/dist ./dist
@@ -70,4 +70,4 @@ HEALTHCHECK --interval=15s --timeout=5s --start-period=20s --retries=3 \
7070
CMD wget -q --spider http://localhost:5100/ping
7171

7272
# 启动应用
73-
CMD ["yarn", "start"]
73+
CMD ["npm", "start"]

0 commit comments

Comments
 (0)